Skip to content

Layout blockGap / spacing: Add support for gap set at the block level in theme.json and global styles #39789

@andrewserong

Description

@andrewserong

Following on from #39601 where we removed the blockGap / block spacing controls in global styles (since the gap value is not currently supported at the block level in global styles), this issue proposes a way to add it back in!

As of #37360 where the CSS variable approach for blockGap was removed, we haven't had support for blockGap at the individual block level in global styles or theme.json. One possible path forward to re-instating it could be:

  • Every block that uses the layout support is server-rendered and currently attempts to grab the block gap value from the block's attributes, and if it doesn't exist, falls back to using the global blockGap CSS variable.
  • Can we add in logic in layout.php and in the JS rendering for the layout support so that if the block's attributes do contain a blockGap setting we then look-up theme.json to grab the blockGap value if one is set at the corresponding block name level?
  • If this approach works, also roll it out to the Gallery block's custom code that implements gap support.

Metadata

Metadata

Labels

Global StylesAnything related to the broader Global Styles efforts, including Styles Engine and theme.json[Type] EnhancementA suggestion for improvement.

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions