Need help with Spacing Support in block.json #53603
-
Hello, I'm stuck out of the blue again, my block supports My "supports":
My "attributes":
Expected to see padding-top 64px by default in my block as promised in documentation. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
That bit of documentation isn't instructing how to set defaults but merely giving an (apparently incorrect) example of what the attributes will look like once they been customized by the user. To use them as the default they have to be under the "attributes": {
"style": {
"type": "object",
"default": {
"spacing":{"padding":{"top":"64px"}}
}
}
} I figured this out by setting padding on an example block and then switching to the Code editor to see how the attributes were output. For example, here’s how it looks using presets:
It's good to keep in mind in case you need to figure out how other block supports apply any attribute values. |
Beta Was this translation helpful? Give feedback.
-
Note for anyone else looking to do this: as of now you need to use the computed value (i.e |
Beta Was this translation helpful? Give feedback.
-
@spencerfinnell |
Beta Was this translation helpful? Give feedback.
That bit of documentation isn't instructing how to set defaults but merely giving an (apparently incorrect) example of what the attributes will look like once they been customized by the user. To use them as the default they have to be under the
default
property of your attribute. Then spacing settings have to be under thespacing
property (this is left out in the doc’s example). Like so:I figured this out by setting padding on an example block and then switching to the Code editor to see how the attributes were output. For example, he…