Use Global Styles or theme.json
to style individual blocks
#33977
Comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What problem does this address?
There's no secret that theme developers have been frustrated with the ability to style blocks.
There are a number of issues here:
Full-site editing introduces the
theme.json
file, which is intended to fix all of these issues. Because theme developers use Global Styles to express how they want a block to be styled. And WordPress takes care of translating these instructions to CSS.This is a win-win situation: WordPress can evolve its blocks without needing to keep existing markup. And theme developers can be sure that their themes don't break when WordPress upgrades.
But this is not without drawbacks. It's common for block styles to be so specific that they overload styles provided by
theme.json
. It's also not easy to debug, as the default block styles are still loaded, and then overloaded by the Global Styles of the theme.What is your proposed solution?
Blocks should use the same styling mechanism as themes do. And that is Global Styles.
Because every attribute under the
styles
key could be used for blocks as well. There's no reason for example why a block would need to use CSS for margins, if Global Styles could be used.The benefits are two-fold:
theme.json
, then blocks as the building pieces of themes need to do the same. This would also prevent future bugs between default styles and theme styles, as both are handled through the same mechanism.The text was updated successfully, but these errors were encountered: