Skip to main content
Block Styles allow you to provide alternative visual styles for existing blocks without creating entirely new blocks. Styles work by adding a CSS class to the block’s wrapper, which you can target with custom CSS.

How Block Styles Work

When a user selects a block style:
  1. A className is added to the block wrapper: is-style-{style-name}
  2. You style this class with CSS
  3. The user can switch between styles in the block toolbar

Registering Block Styles

JavaScript Registration

Use registerBlockStyle() to add a style to an existing block:
This adds an is-style-fancy-quote class when selected.

PHP Registration

Register styles from PHP using register_block_style():

Style Properties

Required Properties

name

The identifier used to compute the CSS class.

label

Human-readable label shown in the block toolbar.

Style Implementation

Choose one of three methods to provide CSS:

1. inline_style

Provide inline CSS directly:

2. style_handle

Reference an already-registered stylesheet:

3. style_data

Use theme.json-like notation for user-editable styles:
With style_data, users can modify the style using the Global Styles UI.

Optional Properties

isDefault

Mark a style as the default (no custom class is added):

Unregistering Block Styles

JavaScript Unregistration

Wrap in wp.domReady() and declare wp-edit-post as a dependency to ensure the style is registered before you unregister it.
PHP code to enqueue:

PHP Unregistration

PHP unregister_block_style() only works with styles registered on the server using register_block_style(). It cannot unregister client-side registered styles.

Complete Examples

Example 1: Simple Style with Inline CSS

Example 2: Style with External Stylesheet

PHP:
CSS (block-styles.css):

Example 3: Multiple Styles for One Block

Example 4: JavaScript Registration

CSS:

Block Styles vs Block Variations

Use Block Styles when you only need to change appearance with CSS. Use Block Variations when you need to:
  • Set initial attributes
  • Configure inner blocks
  • Change block behavior
  • Override default values

Combining Styles and Variations

You can use both together:

Styling Best Practices

  1. Use specific selectors: Target the full class path to avoid conflicts
  1. Respect theme styles: Build on existing block styles rather than overriding everything
  1. Provide fallbacks: Ensure styles work across different themes
  2. Test in editor and frontend: Styles should work in both contexts
  3. Consider color schemes: Support light and dark modes when relevant

Common Use Cases

Button Styles

Image Styles

Heading Styles

Resources