Skip to content

Iterate on absorbing block styles as part of the global styles mechanism #45198

@oandregal

Description

@oandregal

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:

  • default (WordPress bundled theme.json)
  • blocks (__experimentalStyle from block.json)
  • theme (the own theme's theme.json
  • user (the styles provided via the global styles sidebar)

If block's CSS is not fully absorbed, the goal is not complete.

How

The current experimental implementation uses a __experimentalStyle key in the block.json of 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.json that could help address the style variations issues (see).

Current status

Blocks

  • Button
    • Added partial support in #34180
    • Partially remove styles in #41822
    • Remove all remaining styles in #41934
  • Pullquote
    • Added partial support in #43195
  • Navigation
    • Added partial support in #41898
  • Table
  • File
  • Audio
  • Embed
  • Image
  • Video

Issues

.wp-block-button { border-radius: 9999px; }
.wp-block-button.is-style-squared { border-radius: 0; }

Metadata

Metadata

Assignees

No one assigned

    Labels

    Global StylesAnything related to the broader Global Styles efforts, including Styles Engine and theme.json[Feature] Block APIAPI that allows to express the block paradigm.[Type] Tracking IssueTactical breakdown of efforts across the codebase and/or tied to Overview issues.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions