-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Description
Description
Gutenberg currently exposes helper functions in @wordpress/block-editor to generate CSS classes and inline styles for several block supports when their serialization is intentionally skipped, for example:
__experimentalGetBorderClassesAndStyles
__experimentalGetColorClassesAndStyles
__experimentalGetShadowClassesAndStyles
__experimentalGetSpacingClassesAndStyles
getTypographyClassesAndStyles
These helpers are very useful in blocks where color, border, spacing, shadow or typography support is not serialized on the wrapper element, but the corresponding classes/styles still need to be generated and applied to inner elements.
However, there does not seem to be an equivalent helper for Dimensions block support (e.g. width / min-height / aspect-ratio where applicable). There is no:
__experimentalGetDimensionsClassesAndStyles
Problem
When a block opts out of dimensions support serialization, there is currently no official utility to retrieve the generated classes/styles for dimensions in the same way as the other supports. This makes handling dimensions inconsistent compared to color, spacing, border, shadow, and typography, and often requires re-implementing logic that core already handles internally.
Expected behavior
Provide an experimental helper similar to the others, for example:
__experimentalGetDimensionsClassesAndStyles
that returns { className, style } for the dimensions block support, allowing developers to apply those values to inner elements when needed.
Why this matters
- Improves consistency across block support APIs
- Reduces duplication of internal logic in custom blocks
- Makes advanced block layouts easier to implement correctly