A flexible layout component using CSS Flexbox for consistent spacing and alignment. Built on design tokens for predictable spacing values.
import { Stack } from '@wordpress/ui';
LinksPermalink to this section
PropsPermalink to this section
| Name | Default | Description |
|---|---|---|
direction |
The direction of the stack. | |
gap | undefined |
The amount of space between each child element using design system tokens. |
align | 'initial' |
The alignment of the stack items along the cross axis. |
justify | 'initial' |
The alignment of the stack items along the main axis. |
wrap |
Whether the stack items should wrap to the next line. | |
children |
The content to be rendered inside the component. | |
className |
CSS class name to apply to the element. | |
style |
CSS style to apply to the element. | |
render |
Replaces the component’s default HTML element using a given React element, or a function that returns a React element. |
ExamplesPermalink to this section
DefaultPermalink to this section
const Default = () => <Stack gap="md">{[
<DemoBox key="demoBox" />,
<DemoBox variant="lg" key="demoBox-2" />,
<DemoBox key="demoBox-3" />,
<DemoBox key="demoBox-4" />,
<DemoBox variant="lg" key="demoBox-5" />,
<DemoBox key="demoBox-6" />,
]}</Stack>;
NestedPermalink to this section
const Nested = () => <Stack align="center" justify="center">{[
<DemoBox variant="lg" key="demoBox" />,
<Stack gap="lg" key="stack">
<DemoBox />
<DemoBox />
</Stack>,
<DemoBox variant="lg" key="demoBox-2" />,
<Stack direction="column" key="stack-2">
<DemoBox />
<DemoBox />
</Stack>,
<DemoBox variant="lg" key="demoBox-3" />,
]}</Stack>;