Better block style registration : organize and create styles by category #33093
Labels
[Feature] Theme Style Variations
Related to style variations provided by block themes
[Status] Duplicate
Used to indicate that a current issue matches an existing one and can be closed
What problem does this address?
As a custom theme developer, I'd like to give editors a finer control on how they control margins to give them a great tailor-made editor experiences.
Many time lately I've asked to add additional option controls for margins and I've done it in two different ways :
– By registering block style (
wp.blocks.registerBlockStyle
) : e.g I can register a 'no-margin' or 'lg-margin' preset and add styles accordingly both in the editor and the frontend. This becomes tricky when they want a more granular controls for both top and bottom margins (but potentially side margins, padding, you name it).In addition to that, I struggle to control the style preview and would prefer to disable the style image preview rather than having something irrelevant (= decreasing cognitive load). Also styles are already registered for other things which can quickly become messy if you have a lot of them so that would help to organize them by category.
– By adding custom classes : this is a bulletproof approach but not an ideal experience for editors
What is your proposed solution?
Currently I love how we can extend native Gutenberg appearance with registerBlockStyle method, it is simple and effective to controls how the blocks look with the help of CSS classes.
Now, let's say with we want to extend our Columns block with upper and lower margins options (let's say 4 presets : xs, sm, md, lg) + multiple gutter options, that would be nice if you could do something like this :
If editor were to choose this style, a
is-style-upper-margin-sm
would be added to the block.The text was updated successfully, but these errors were encountered: