Block background color styles: an overview #43110
Labels
[Feature] Design Tools
Tools that impact the appearance of blocks both to expand the number of tools and improve the experi
Global Styles
Anything related to the broader Global Styles efforts, including Styles Engine and theme.json
[Package] Block library
/packages/block-library
[Type] Bug
An existing feature does not function as intended
Description
When we add a background color to a block, padding also gets added to it. This comes from the base styles for the blocks themselves (so the
style.scss
file for each block in the block library).There are a bunch of issues already open about this behaviour:
And other issues are being affected by it:
Additionally, setting a child of a block with background color to full width doesn't work:
(This is with Empty theme; other themes may have added custom styles to work around this problem. But they shouldn't have to.)
The main reason I'm opening a new one is, firstly, to consolidate all the reports in one place, and secondly in hope that we can find a way forward.
The styles in question already have very low specificity, so they are easy to override, but the main problem in a block theme scenario is that because they come from a stylesheet, we have no way of knowing their value, so we're unable to take them into account when exposing padding controls (which is the problem in #42173) or when generating alignment styles (the problem with the full width block above).
Ideally, we wouldn't output these styles at all, at least for block themes. One idea would be to move them to a classic-only stylesheet.
Ideas and concerns appreciated!
(I'm labelling this as a bug because it causes buggy behaviour in some circumstances, though it is a known "feature".)
Step-by-step reproduction instructions
Also check the reproduction scenarios on the linked issues!
Screenshots, screen recording, code snippet
No response
Environment info
No response
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes
The text was updated successfully, but these errors were encountered: