Skip to content

Flex

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

Item 1
Item 2
Item 3
export const Default: Story = {
  render: (args) => (
    <Flex {...args}>
      <Box>Item 1</Box>
      <Box>Item 2</Box>
      <Box>Item 3</Box>
    </Flex>
  ),
};

Column

Item 1
Item 2
Item 3
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

Short
Tall
Medium
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

Left
Center
Right
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

Item 1
Item 2
Item 3
Item 4
Item 5
Item 6
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

Grows to fill
Never shrinks
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

First in the DOM
Second in the DOM
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

NameTypeRequiredDefaultDescription
direction'row' | 'row-reverse' | 'column' | 'column-reverse'No'row'

Flex direction.

**Accessibility:** row-reverse and column-reverse reverse the *visual* order only. Tab order and screen-reader reading order still follow the DOM, so they run opposite to what sighted users see (WCAG 1.3.2, 2.4.3). For focusable or meaningful content, reorder the DOM instead; a development warning fires when a reversed Flex contains focusable elements.

wrap'nowrap' | 'wrap' | 'wrap-reverse'No

Flex wrap behavior. wrap-reverse reverses the visual line order only (see direction).

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.

inlinebooleanNo

Whether to use inline-flex instead of flex.

growbooleanNo

Whether the flex container should grow to fill available space in its own flex parent.

shrinkbooleanNo

How the container shrinks in its own flex parent: false prevents shrinking (shrink-0), true sets shrink explicitly (the CSS default, useful to undo an inherited shrink-0). Unset emits no class.

asReact.ElementTypeNo'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

PartClass
rootwave-flex