Flex
A flexbox layout container with token-based gaps.
Reversed directions (row-reverse, column-reverse, wrap="wrap-reverse") change the visual order only: keep them for decorative or static content and reorder the DOM for anything focusable (a development warning fires otherwise).
Examples
Default
export const Default: Story = {
render: (args) => (
<Flex {...args}>
<Box>Item 1</Box>
<Box>Item 2</Box>
<Box>Item 3</Box>
</Flex>
),
};Column
export const Column: Story = {
args: {
direction: 'column',
style: { width: 300 },
},
render: (args) => (
<Flex {...args}>
<Box>Item 1</Box>
<Box>Item 2</Box>
<Box>Item 3</Box>
</Flex>
),
};Align Center
export const AlignCenter: Story = {
args: {
align: 'center',
className: 'border border-dashed border-wave-border',
style: { height: 120 },
},
render: (args) => (
<Flex {...args}>
<Box style={{ height: 40 }}>Short</Box>
<Box style={{ height: 80 }}>Tall</Box>
<Box style={{ height: 60 }}>Medium</Box>
</Flex>
),
};Space Between
export const SpaceBetween: Story = {
args: {
justify: 'between',
className: 'border border-dashed border-wave-border p-2',
},
render: (args) => (
<Flex {...args}>
<Box>Left</Box>
<Box>Center</Box>
<Box>Right</Box>
</Flex>
),
};Wrapped
export const Wrapped: Story = {
args: {
wrap: 'wrap',
gap: 'sm',
style: { width: 300 },
},
render: (args) => (
<Flex {...args}>
<Box>Item 1</Box>
<Box>Item 2</Box>
<Box>Item 3</Box>
<Box>Item 4</Box>
<Box>Item 5</Box>
<Box>Item 6</Box>
</Flex>
),
};Grow Shrink
export const GrowShrink: Story = {
args: {
style: { width: 500 },
},
render: (args) => (
<Flex {...args}>
<Flex grow className="rounded bg-wave-selected p-3 text-wave-selected-foreground">
Grows to fill
</Flex>
<Flex shrink={false} className="rounded border border-wave-border bg-wave-muted px-4 py-3">
Never shrinks
</Flex>
</Flex>
),
};Row Reverse
export const RowReverse: Story = {
args: {
direction: 'row-reverse',
justify: 'end',
},
render: (args) => (
<Flex {...args}>
<Box>First in the DOM</Box>
<Box>Second in the DOM</Box>
</Flex>
),
};Props
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
direction | 'row' | 'row-reverse' | 'column' | 'column-reverse' | No | 'row' | Flex direction. **Accessibility:** |
wrap | 'nowrap' | 'wrap' | 'wrap-reverse' | No | Flex wrap behavior. | |
align | 'start' | 'center' | 'end' | 'stretch' | 'baseline' | No | Cross-axis alignment of items. | |
justify | 'start' | 'center' | 'end' | 'between' | 'around' | 'evenly' | No | Main-axis justification of items. | |
gap | 'none' | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | No | Gap size between flex items. | |
inline | boolean | No | Whether to use inline-flex instead of flex. | |
grow | boolean | No | Whether the flex container should grow to fill available space in its own flex parent. | |
shrink | boolean | No | How the container shrinks in its own flex parent: | |
as | React.ElementType | No | 'div' | Render as a different element or component (its props are type-checked). |
Any other prop is passed to the element it renders (HTMLDivElement).
Stable class names
| Part | Class |
|---|---|
root | wave-flex |