Skip to content

Custom CSS cannot be used with original blocks lacking block.json #75766

Closed

Description

@nendeb

Description

While custom CSS appears to be enabled in WordPress 7.0,
it does not function properly with older original blocks lacking block.json.

Please consider either providing backward compatibility support or disabling customCSS entirely.

Step-by-step reproduction instructions

For original blocks without block.json,
the custom CSS input field appears.
Entering CSS works in the admin interface, but viewing the code editor shows the CSS is not applied.

Since the CSS is not applied on the frontend, the display is not correct.

Screenshots, screen recording, code snippet

No response

Environment info

WordPress 7.0-alpha
Theme Twenty Sixteen

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

  • Yes

Please confirm which theme type you used for testing.

  • Block
  • Classic
  • Hybrid (e.g. classic with theme.json)
  • Not sure

Activity

  1. added
    [Type] BugAn existing feature does not function as intended
    on Feb 20, 2026
  2. added
    Global StylesAnything related to the broader Global Styles efforts, including Styles Engine and theme.json
    on Feb 20, 2026
  3. Mamaduka commented on Feb 20, 2026

    @Mamaduka
    Member

    cc @glendaviesnz

    @nendeb, can you share an example block? While block.json is nice to have, it's not required, and the same configuration can be done via PHP.

  4. nendeb commented on Feb 20, 2026

    @nendeb
    Author

    cc@glendaviesnz
    Thank you.

    I'm sorry, but there are no blocks I can share.
    What we currently know is
    the case where block.json is not used with server-side rendering.

    Also, adding

        style: {
            type: ‘object’,
        },
    

    to the attributes makes it display correctly, but I'm not sure if this is correct.

    As I mentioned earlier, I believe it is undesirable to force existing blocks that have been functioning normally to be modified simply because they lack a block.json file.

    Please consider how to address this.

  5. t-hamano commented on Feb 21, 2026

    @t-hamano
    Contributor

    The underlying problem doesn't seem to be related to block.json. Perhaps the results differ depending on whether or not the attributes.style object is present.

    Try these steps:

    1. Run the code in your browser console and register the custom block.
    2. Insert the block into a post.
    3. Add custom CSS.
    4. Open your code editor.
    5. Verify that the custom CSS data is present.

    The following code does not work with custom CSS:

    wp.blocks.registerBlockType('my-plugin/my-custom-block', {
    	apiVersion: 3,
    	title: 'Custom Block',
    	edit: function () {
    		return wp.element.createElement(
    			'p',
    			wp.blockEditor.useBlockProps(),
    			'Hello World'
    		);
    	},
    });

    The following code works with custom CSS:

    wp.blocks.registerBlockType('my-plugin/my-custom-block', {
    	apiVersion: 3,
    	title: 'Custom Block with color support',
    	supports: {
    		color: {
    			text: true
    		}
    	},
    	edit: function () {
    		return wp.element.createElement(
    			'p',
    			wp.blockEditor.useBlockProps(),
    			'Hello World'
    		);
    	},
    });
    wp.blocks.registerBlockType('my-plugin/my-custom-block', {
    	apiVersion: 3,
    	title: 'Custom Block with style object',
    	attributes: {
    		style: {}
    	},
    	edit: function () {
    		return wp.element.createElement(
    			'p',
    			wp.blockEditor.useBlockProps(),
    			'Hello World'
    		);
    	},
    });

    Please consider either providing backward compatibility support or disabling customCSS entirely.

    Custom CSS support can be disabled.

    wp.blocks.registerBlockType('my-plugin/my-custom-block', {
    	apiVersion: 3,
    	title: 'Block without custom CSS support',
    	supports: {
    		customCSS: false
    	},
    	edit: function () {
    		return wp.element.createElement(
    			'p',
    			wp.blockEditor.useBlockProps(),
    			'Hello World'
    		);
    	},
    });
  6. moved this from ❓ Triage to 🏗️ In Progress in WordPress 7.0 Editor Taskson Feb 21, 2026
  7. nendeb commented on Feb 21, 2026

    @nendeb
    Author

    t-hamano

    Thank you.

    attributes: {style: {}},
    supports: {color: {text: true},

    Both have been verified to work.
    I don't understand why adding color makes it work, but since it seems you're accommodating this as backward compatibility as requested, I appreciate it.

  8. moved this from 🏗️ In Progress to ✅ Done in WordPress 7.0 Editor Taskson Feb 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Global StylesAnything related to the broader Global Styles efforts, including Styles Engine and theme.json[Status] In ProgressTracking issues with work in progress[Status] Needs More InfoFollow-up required in order to be actionable.[Type] BugAn existing feature does not function as intended

Type

No type

Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions