diff --git a/lib/block-supports/layout.php b/lib/block-supports/layout.php index eaca6d4c70cc8..060aa07901810 100644 --- a/lib/block-supports/layout.php +++ b/lib/block-supports/layout.php @@ -47,6 +47,13 @@ function gutenberg_get_layout_style( $selector, $layout, $has_block_gap_support $gap_value = isset( $gap_value['top'] ) ? $gap_value['top'] : null; } if ( null !== $gap_value && ! $should_skip_gap_serialization ) { + // Get spacing CSS variable from preset value if provided. + if ( is_string( $gap_value ) && str_contains( $gap_value, 'var:preset|spacing|' ) ) { + $index_to_splice = strrpos( $gap_value, '|' ) + 1; + $slug = _wp_to_kebab_case( substr( $gap_value, $index_to_splice ) ); + $gap_value = "var(--wp--preset--spacing--$slug)"; + } + array_push( $layout_styles, array(