Add Styles to the Gutenberg Editor

Load the stylesheet in the correct editor context so block content and the frontend can share a visual style.

To style block content, load a stylesheet with enqueue_block_assets. This serves the frontend and the editor’s content context, including the iframe. Editor interface controls use a separate editor asset hook.


Add Styles to Gutenberg editor WordPress.

add_action('enqueue_block_assets', function () {
    $path = get_stylesheet_directory() . '/build/editor.css';
    if (!file_exists($path)) { return; }
    wp_enqueue_style('my-block-content',
        get_stylesheet_directory_uri() . '/build/editor.css',
        [], filemtime($path));
});

Content CSS and interface CSS

Use enqueue_block_editor_assets for editor interface components and enqueue_block_assets for block content. See the asset-loading guide and our block-style tutorial.

Good things, occasionally.

Fresh ideas, useful tools and better ways to build. Delivered when we have something worth sharing.