Allow registering additional CSS selectors for blocks (to be used by theme.json
)
#34196
Labels
Global Styles
Anything related to the broader Global Styles efforts, including Styles Engine and theme.json
[Type] Discussion
For issues that are high-level and not yet ready to implement.
This issue stems from this conversation #34141 (comment)
The issue
There're components of the design for which we don't have a way to change all "components of a type" at once. For example, it seems desirable that the button block, the button within search, and others are addressable all at once.
There're components of the design that can't be addressed yet. For example, the button in the search block.
Proposal
Ideally, complex blocks use the button block internally, which would solve this issue - styles set for
core/button
viatheme.json
would target all the buttons. I understand there may be valid reasons why blocks can't or don't use inner blocks. It may be also difficult to convert the button to an element. I'd like to offer alternative thoughts.Right now,
namespace/blockname
in theme.json resolves to the CSS selector of the block: by default it'll bewp-block-namespace-blockname
and blocks can define their own by using the__experimentalSelector
support flag. For example,core/button
resolves to.wp-block-button__link
.The idea would be that we allow registering additional CSS selectors for blocks. As a result, this:
would be converted into the following CSS:
Implementation
It could be:
Block-driven. It's the block's responsibility to attach the additional selector. We enable the search block to say "I want the styles of the button block applied to my inner button".
Theme-driven. It's the theme's responsibility to attach the additional selector.
I haven't explored all the ramifications of this idea but wanted to share and see what others think.
The text was updated successfully, but these errors were encountered: