Skip to content

Snippet: Unregistering block styles #427

@bph

Description

@bph

Discussed in #423

Originally posted by ryanwelcher October 24, 2025
This came up in one of my live streams and it required some thinking to get it working. This snippet will unregister all registered block styles for all blocks.

This can be tweaked to only target specific blocks as well.

/**
 * WordPress dependencies
 */
import { registerPlugin } from '@wordpress/plugins';
import { useSelect, select as inlineSelect } from '@wordpress/data';
import { store as blockStore, unregisterBlockStyle } from '@wordpress/blocks';
import { useEffect } from '@wordpress/element';

const Render = () => {
	const types = useSelect(
		( select ) =>
			select( blockStore )
				.getBlockTypes()
				?.map( ( type ) => type.name ),

		[]
	);

	useEffect( () => {
		types.forEach( ( type ) => {
			const blockStyles =
				inlineSelect( blockStore ).getBlockStyles( type );

			blockStyles.forEach( ( style ) => {
				unregisterBlockStyle( type, style.name );
			} );
		} );
	}, [ types ] );

	return null;
};

registerPlugin( 'my-plugin-remove-block-styles', {
	render: Render,
} );

```</div>

Metadata

Metadata

Assignees

Type

No type

Projects

Status

To-do

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions