3

In the editor (Gutenberg) is there a way to disable specific settings in the right panel of a specific block?

For example each button in the buttons block has these settings I would like to disable:

Right column settings

I know with the color options here there is an editor styles palette I can return empty which will remove the color option - but this removes the color option across all blocks, I just want to remove these style based settings within the buttons block only.

I'm wondering if editor.BlockEdit may help here but not sure on how to target it to the buttons block or specify the restricted options within it.

I can also see posts referencing removeEditorPanel but that appears to be just for the page based options like featured image, page attributes, etc

Maybe the functionality to do this does not exist?

1 Answer 1

1

Removing specific panels or features for a block is done on a per block basis using various hooks (https://github.com/WordPress/gutenberg/issues/15450#issuecomment-635255936)

Update (August 2021)

Removing specific panels (that would allow for customization of a block) can now be done through the theme.json aka global settings and styles which allows you to customize settings (colors, typography, etc) for an entire website or on a block-level.

Requires WordPress 5.8 or newer.

Note that only certain core blocks have these supports built in.

For specifically disabling the custom colors in the button block,

You'll need to first create a theme.json file in base folder of your theme; need to add the required info

{
    "version": 1,
    "settings": { 

and then add the following:

  "core/button": {
      "color": {
          "custom": false
      }
    },

so your full theme.json would look like:

    {
        "version": 1,
        "settings": { 

    "blocks": {
      "core/button": {
          "color": {
              "custom": false
          }
        },
    }, 
}
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.