-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
blockGap & vertical margins #39122
Comments
Thanks for opening this issue @Humanify-nl. You've articulated nicely some of the issues of attempting to use CSS variables for spacing. A refactor of the Layout block support has been merged in #40875 which adjusts how the gap styles are output, so that direct values are used where possible instead of CSS variables. Setting a There's still more work to do to improve the layout and blockGap behaviour (tracked in #39336), but hopefully this gets us a large part of the way there. |
Thanks for the compliment @andrewserong, happy to contribute. This change is a big step forward! |
Is there anything in this issue that still needs to be implemented @Humanify-nl ? |
Let's close this issue, as it needs more info to be actionable. Please feel free to reopen again if there is more information. 🙏 |
@skorasaurus @priethor Thanks! I rarely have issues with block gaps recently since I can just drop my variables in theme.json and they work great as defaults. The (I believe 5.9) change with spacing tokens (awesome) has made it a lot more comfortable to expose block gap controls to clients as well. |
Great to hear that, @Humanify-nl! 🙌 |
What problem does this address?
There have been some issues with controlling the blockGap programmatically on a per-block level in a FSE theme.
I am aware we can set the gap in the editor for individual blocks. I'm talking about cases where we will not expose this exact layout control to clients in a wordpress editor environment.
To get what I need, is to reset the
--wp--style--block-gap
value on the block level in the theme CSS (for example in.wp-block-buttons
).This works great, except for one issue: Now the 'root-container' spacing rules will adopt this value to set top-margins (the > *+ * rule), which makes the css variable less ideal for this purpose and needs css bandaid, to override the top margins.
Sidenote: Maybe this is in itself a bug, because I would say the 'root-level vertical spacing rules' should use the global theme blockgap, and not that of the specific block
I think this exposes the problem of gap. It wants to also be vertical margins, but it actually isn't, it's a gap! There is a reason gap exists in CSS for this specific role.
Current situation:
{ "spacing": { "blockGap": "value" } }
"spacing": { "blockGap": "0.5rem"}
, it won't work (this was a lesser of two evils choice 37360).So to be precise: the specific problem this feature request addresses is that we have one value for vertical margins between blocks and also need to use this value as a gap for flex columns (such as gallery, buttons, social-links).
What is your proposed solution?
I think there should be a distinction between:
In this case I'd say
block-gap
&block-inner-gap
make sense. ORblock-gap
&block-margin
maybe.This way we can:
The text was updated successfully, but these errors were encountered: