Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
d06e41f
Add space-around and space-evenly justification
Sukhendu2002 Aug 8, 2025
fb1e233
feat(block-editor): update justification panel
Sukhendu2002 Sep 24, 2026
b3c69e9
fix(block-editor): contain justification trigger
Sukhendu2002 Sep 24, 2026
eb4346b
fix: show full justification label
Sukhendu2002 Sep 24, 2026
9556a71
feat: support additional flex justification
Sukhendu2002 Sep 24, 2026
080c9d3
Add Core backport for #71129
Sukhendu2002 Sep 24, 2026
88ccb1d
feat: refine flex justification options
Sukhendu2002 Sep 25, 2026
e782ed2
Merge branch 'trunk' into add/buttons-block-space-justification-options
Sukhendu2002 Sep 28, 2026
1052844
fix: complete flex justification support
Sukhendu2002 Sep 28, 2026
46b0f74
fix: prevent Justification select crash on Stack to Row switch and co…
Sukhendu2002 Oct 14, 2026
b03ed0d
Merge branch 'trunk' into add/buttons-block-space-justification-options
Sukhendu2002 Oct 14, 2026
c3e0d83
Merge branch 'trunk' into add/buttons-block-space-justification-options
Sukhendu2002 Oct 14, 2026
2b2d9d3
Merge remote-tracking branch 'upstream/trunk' into add/buttons-block-…
Sukhendu2002 Oct 23, 2026
ad80f85
fix: show icons in flex justification controls
Sukhendu2002 Oct 23, 2026
79fe64f
Merge branch 'trunk' into add/buttons-block-space-justification-options
Sukhendu2002 Oct 23, 2026
279f5b9
docs: move justification notes to Unreleased
Sukhendu2002 Oct 23, 2026
c532c77
test: migrate justification test to TypeScript
Sukhendu2002 Oct 23, 2026
8982886
Merge remote-tracking branch 'upstream/trunk' into add/buttons-block-…
Sukhendu2002 Nov 3, 2026
db25d85
fix: simplify flex justification controls
Sukhendu2002 Nov 3, 2026
6d185cd
Merge branch 'trunk' into add/buttons-block-space-justification-options
Sukhendu2002 Nov 3, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions backport-changelog/7.2/13710.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
https://github.com/WordPress/wordpress-develop/pull/13710

* https://github.com/WordPress/gutenberg/pull/71129
2 changes: 2 additions & 0 deletions docs/explanations/architecture/styles.md
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,8 @@ The current semantic class names that can be output by the Layout block support
- `is-content-justification-center`: When a block explicitly sets `justifyContent` to `center`.
- `is-content-justification-right`: When a block explicitly sets `justifyContent` to `right`.
- `is-content-justification-space-between`: When a block explicitly sets `justifyContent` to `space-between`.
- `is-content-justification-space-around`: When a block explicitly sets `justifyContent` to `space-around`.
- `is-content-justification-space-evenly`: When a block explicitly sets `justifyContent` to `space-evenly`.
- `is-nowrap`: When a block explicitly sets `flexWrap` to `nowrap`.

### Opting out of generated layout styles
Expand Down
6 changes: 5 additions & 1 deletion lib/block-supports/layout.php
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,11 @@ function gutenberg_get_layout_style( $selector, $layout, $has_block_gap_support
);

if ( 'horizontal' === $layout_orientation ) {
$justify_content_options += array( 'space-between' => 'space-between' );
$justify_content_options += array(
'space-between' => 'space-between',
'space-around' => 'space-around',
'space-evenly' => 'space-evenly',
);
$vertical_alignment_options += array( 'stretch' => 'stretch' );
} else {
$justify_content_options += array( 'stretch' => 'stretch' );
Expand Down
5 changes: 5 additions & 0 deletions packages/block-editor/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@

- `RichTextToolbarButton`: Passing a `name` prop will no longer render a dedicated Fill unless that name corresponds to a known core toolbar format ([#85843](https://github.com/WordPress/gutenberg/pull/85843)).

### New Features

- Flex layout: Add Space around and Space evenly justification options, using a select control with icons and labels in the Layout panel ([#71129](https://github.com/WordPress/gutenberg/pull/71129)).
- `JustifyContentControl`: Include Space around and Space evenly in the default controls ([#71129](https://github.com/WordPress/gutenberg/pull/71129)).

### Enhancements

- Migrate `BackgroundClipControl` to `@wordpress/ui` `SelectControl`. Internal markup and CSS classes have changed; custom CSS overrides may need updates ([#86046](https://github.com/WordPress/gutenberg/pull/86046)).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

The `JustifyContentControl` component renders a toolbar that displays justify options for the selected block.

This component is used to set the flex justification for the elements in the block, allowing to justify `left`, `center`, `right`, and `space-between`. In comparison, the alignment options are for the block itself.
This component is used to set the flex justification for the elements in the block, allowing to justify `left`, `center`, `right`, `space-between`, `space-around`, and `space-evenly`. In comparison, the alignment options are for the block itself.

See the Navigation block for an example usage.

Expand Down Expand Up @@ -33,6 +33,8 @@ const MyJustifyToolbar = ( { attributes, setAttributes } ) => (
items-justified-center
items-justified-right
items-justified-space-between
items-justified-space-around
items-justified-space-evenly

_Note:_ In this example that we render `JustifyContentControl` as a child of the `BlockControls` component.

Expand All @@ -41,7 +43,7 @@ _Note:_ In this example that we render `JustifyContentControl` as a child of the
#### `allowedControls`

- **Type:** `string[]`
- **Default:** `[ 'left', 'center', 'right', 'space-between' ]`
- **Default:** `[ 'left', 'center', 'right', 'space-between', 'space-around', 'space-evenly' ]`

An array of strings for what controls to show, by default it shows all.

Expand All @@ -50,7 +52,7 @@ An array of strings for what controls to show, by default it shows all.
- **Type:** `Function`
- **Required:** Yes

A callback function invoked when the toolbar's justification value is changed via an interaction with any of the toolbar's buttons. Called with the new alignment value (ie: `left`, `center`, `right`, `space-between`, `undefined`) as the only argument.
A callback function invoked when the toolbar's justification value is changed via an interaction with any of the toolbar's buttons. Called with the new alignment value (ie: `left`, `center`, `right`, `space-between`, `space-around`, `space-evenly`, `undefined`) as the only argument.

#### `popoverProps`

Expand All @@ -65,7 +67,7 @@ Use this object to modify props available for the `Popover` component that are n

- **Type:** `String`
- **Default:** `undefined`
- **Options:**: `left`, `center`, `right`, `space-between`
- **Options:**: `left`, `center`, `right`, `space-between`, `space-around`, `space-evenly`

The current value of the alignment setting. You may only choose from the `Options` listed above.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,11 @@
.items-justified-space-between {
justify-content: space-between;
}

.items-justified-space-around {
justify-content: space-around;
}

.items-justified-space-evenly {
justify-content: space-evenly;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I don't think this test is necessary. It only asserts that the labels of the default allowedControls array are rendered in order, which essentially mirrors a constant.

Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { expect, test, vi } from 'vitest';
import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { createElement } from '@wordpress/element';
import JustifyContentUI from '../ui';

test( 'lists every justification option by default', async () => {
const user = userEvent.setup();
const { unmount } = render(
createElement( JustifyContentUI, {
value: 'left',
onChange: vi.fn(),
} )
);

await user.click(
screen.getByRole( 'button', { name: 'Change items justification' } )
);

expect(
screen.getAllByRole( 'menuitem' ).map( ( item ) => item.textContent )
).toEqual( [
'Left',
'Center',
'Right',
'Space between',
'Space around',
'Space evenly',
] );

// Cancel delayed popover positioning effects.
unmount();
} );
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@ import type { Dropdown } from '@wordpress/components';
* A justification of the items in a block.
*/
export type JustifyContentValue =
'left' | 'center' | 'right' | 'space-between' | 'stretch';
| 'left'
| 'center'
| 'right'
| 'space-between'
| 'space-around'
| 'space-evenly'
| 'stretch';

/**
* Props of `JustifyContentControl` and `JustifyToolbar`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,32 @@ import {
justifyCenter,
justifyRight,
justifySpaceBetween,
justifySpaceAround,
justifySpaceEvenly,
justifyStretch,
} from '@wordpress/icons';
import { __ } from '@wordpress/i18n';
import { __, _x } from '@wordpress/i18n';
import type { JustifyContentUIProps, JustifyContentValue } from './types';

const icons = {
left: justifyLeft,
center: justifyCenter,
right: justifyRight,
'space-between': justifySpaceBetween,
'space-around': justifySpaceAround,
'space-evenly': justifySpaceEvenly,
stretch: justifyStretch,
};

function JustifyContentUI( {
allowedControls = [ 'left', 'center', 'right', 'space-between' ],
allowedControls = [
'left',
'center',
'right',
'space-between',
'space-around',
'space-evenly',
],
isCollapsed = true,
onChange,
value,
Expand All @@ -42,31 +53,45 @@ function JustifyContentUI( {
{
name: 'left',
icon: justifyLeft,
title: __( 'Justify items left' ),
title: _x( 'Left', 'Flex layout justification option' ),
isActive: 'left' === value,
onClick: () => handleClick( 'left' ),
},
{
name: 'center',
icon: justifyCenter,
title: __( 'Justify items center' ),
title: _x( 'Center', 'Flex layout justification option' ),
isActive: 'center' === value,
onClick: () => handleClick( 'center' ),
},
{
name: 'right',
icon: justifyRight,
title: __( 'Justify items right' ),
title: _x( 'Right', 'Flex layout justification option' ),
isActive: 'right' === value,
onClick: () => handleClick( 'right' ),
},
{
name: 'space-between',
icon: justifySpaceBetween,
title: __( 'Space between items' ),
title: __( 'Space between' ),
isActive: 'space-between' === value,
onClick: () => handleClick( 'space-between' ),
},
{
name: 'space-around',
icon: justifySpaceAround,
title: __( 'Space around' ),
isActive: 'space-around' === value,
onClick: () => handleClick( 'space-around' ),
},
{
name: 'space-evenly',
icon: justifySpaceEvenly,
title: __( 'Space evenly' ),
isActive: 'space-evenly' === value,
onClick: () => handleClick( 'space-evenly' ),
},
{
name: 'stretch',
icon: justifyStretch,
Expand Down
12 changes: 12 additions & 0 deletions packages/block-editor/src/hooks/layout.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,18 @@
.layout-block-support-panel {
.block-editor-hooks__flex-layout-controls {
grid-column: 1 / -1;

> * {
min-width: 0;
}

.block-editor-hooks__flex-layout-justification-item {
flex: 1;
}

.block-editor-hooks__flex-layout-orientation-item {
flex: none;
}
}
}

Expand Down
Loading
Loading