Support

Account

Home Forums Gutenberg Setting the Layout attribute as a default in block.json

Helping

Setting the Layout attribute as a default in block.json

  • Hi all, trying to leverage the core setup a little more across my ACF Blocks, I’m having an issue setting the default Layout Type within the block.json file, looked at the schema etc and still no joy? Anyone got any ideas? Current setup is:

    "attributes": {
    "align": {
    "type": "string",
    "default": "full"
    },
    "backgroundColor": {
    "type": "string",
    "default": "grey"
    },
    "textColor": {
    "type": "string",
    "default": "white"
    },
    "linkColor": {
    "type": "string",
    "default": "white"
    },
    "className": {
    "type": "string",
    "default": "is-style-no-margin"
    },
    "layout": {
    "type": "object",
    "default": {
    "type": "string",
    "enum": ["constrained"]
    }
    }
    },

  • Answered my own question, was taking the schema to literally.

    For anyone else looking:

    "layout": { 
                      "type": "object", 
                      "default": { 
                            "type": "constrained" 
                      } 
                }

    Also make sure the “layout: true” is set within the “supports” array.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.