-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Iterate on absorbing block styles as part of the global styles mechanism #45198
Copy link
Copy link
Closed
Labels
Global StylesAnything related to the broader Global Styles efforts, including Styles Engine and theme.jsonAnything related to the broader Global Styles efforts, including Styles Engine and theme.json[Feature] Block APIAPI that allows to express the block paradigm.API that allows to express the block paradigm.[Type] Tracking IssueTactical breakdown of efforts across the codebase and/or tied to Overview issues.Tactical breakdown of efforts across the codebase and/or tied to Overview issues.
Metadata
Metadata
Assignees
Labels
Global StylesAnything related to the broader Global Styles efforts, including Styles Engine and theme.jsonAnything related to the broader Global Styles efforts, including Styles Engine and theme.json[Feature] Block APIAPI that allows to express the block paradigm.API that allows to express the block paradigm.[Type] Tracking IssueTactical breakdown of efforts across the codebase and/or tied to Overview issues.Tactical breakdown of efforts across the codebase and/or tied to Overview issues.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Follow-up to #33977
Part of #45171, #41232, and #41236.
What
Finalize the work that was started at #34180 to absorb block's CSS as part of the global styles' mechanism.
Why
By absorbing the block's CSS, WordPress will be able to reduce the CSS loaded in the page, themes and users will have a reliable (no specificity issues) and fine-grained mechanism to override styles from lower-level sources.
Note that the global styles' mechanism takes the CSS needs that different sources declare, and creates a single stylesheet that merges them all. The current sources are:
theme.json)__experimentalStylefromblock.json)theme.jsonIf block's CSS is not fully absorbed, the goal is not complete.
How
The current experimental implementation uses a
__experimentalStylekey in theblock.jsonof the block.We could explore other alternatives when/if the current experiment becomes insufficient or ergonomically inconvenient. For example, it was suggested that blocks could also have a separate
styles.jsonthat could help address the style variations issues (see).Current status
Blocks
Issues
theme.jsondon't have these styles in the post editor Styles coming from__experimentalStylesare not enqueued in the post editor for themes withouttheme.json#46818theme.jsonstyles. They are different mechanisms that don't understand each other. See "block styles variations" and "style variations for blocks". As a result, the current mechanism cannot absorb the following CSS: