diff --git a/packages/block-library/src/columns/block.json b/packages/block-library/src/columns/block.json index 0cc93b718a89b..4da71db7f2212 100644 --- a/packages/block-library/src/columns/block.json +++ b/packages/block-library/src/columns/block.json @@ -3,6 +3,9 @@ "name": "core/columns", "category": "design", "attributes": { + "gutterSize": { + "type": "number" + }, "verticalAlignment": { "type": "string" } diff --git a/packages/block-library/src/columns/edit.js b/packages/block-library/src/columns/edit.js index 9ad79099af20a..9608743c82fba 100644 --- a/packages/block-library/src/columns/edit.js +++ b/packages/block-library/src/columns/edit.js @@ -52,7 +52,7 @@ function ColumnsEditContainer( { updateColumns, clientId, } ) { - const { verticalAlignment } = attributes; + const { gutterSize, verticalAlignment } = attributes; const { count } = useSelect( ( select ) => { @@ -69,6 +69,10 @@ function ColumnsEditContainer( { const blockProps = useBlockProps( { className: classes, + style: { + '--columns-block-gutter-size': + gutterSize !== undefined ? `${ gutterSize }px` : undefined, + }, } ); const innerBlocksProps = useInnerBlocksProps( blockProps, { allowedBlocks: ALLOWED_BLOCKS, @@ -85,7 +89,7 @@ function ColumnsEditContainer( { /> - + +
); diff --git a/packages/block-library/src/columns/style.scss b/packages/block-library/src/columns/style.scss index 385d5ad26282c..089634a58e283 100644 --- a/packages/block-library/src/columns/style.scss +++ b/packages/block-library/src/columns/style.scss @@ -1,6 +1,7 @@ .wp-block-columns { display: flex; margin-bottom: 1.75em; + --columns-block-gutter-size: #{ $grid-unit-20 * 2 }; // Responsiveness: Allow wrapping on mobile. flex-wrap: wrap; @@ -59,7 +60,7 @@ // Add space between the multiple columns. Themes can customize this if they wish to work differently. // Only apply this beyond the mobile breakpoint, as there's only a single column on mobile. &:nth-child(even) { - margin-left: 2em; + margin-left: var(--columns-block-gutter-size, 2em); } } @@ -83,7 +84,7 @@ // When columns are in a single row, add space before all except the first. &:not(:first-child) { - margin-left: 2em; + margin-left: var(--columns-block-gutter-size, 2em); } }