Skip to content

Stack

Stack

A one-dimensional layout: items stacked vertically (default) or horizontally with a token gap.

Examples

Default

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

Horizontal

Item 1
Item 2
Item 3
export const Horizontal: Story = {
  args: {
    orientation: 'horizontal',
  },
  render: (args) => (
    <Stack {...args}>
      <Box>Item 1</Box>
      <Box>Item 2</Box>
      <Box>Item 3</Box>
    </Stack>
  ),
};

Gap Sizes

gap="none"

A
B
C

gap="xs"

A
B
C

gap="sm"

A
B
C

gap="md" (default)

A
B
C

gap="lg"

A
B
C

gap="xl"

A
B
C
export const GapSizes: Story = {
  args: {
    gap: 'lg',
  },
  render: (args) => (
    <Stack {...args}>
      {gaps.map((gap) => (
        <div key={gap}>
          <p className="mb-1 font-semibold">
            gap=&quot;{gap}&quot;{gap === 'md' ? ' (default)' : ''}
          </p>
          <Stack orientation="horizontal" gap={gap}>
            <Box>A</Box>
            <Box>B</Box>
            <Box>C</Box>
          </Stack>
        </div>
      ))}
    </Stack>
  ),
};

Centered

Centered content
export const Centered: Story = {
  args: {
    align: 'center',
    justify: 'center',
    className: 'border border-dashed border-wave-border',
    style: { height: 200 },
  },
  render: (args) => (
    <Stack {...args}>
      <Box>Centered content</Box>
    </Stack>
  ),
};

Wrapped

Item 1
Item 2
Item 3
Item 4
Item 5
Item 6
export const Wrapped: Story = {
  args: {
    orientation: 'horizontal',
    wrap: true,
    gap: 'sm',
    style: { width: 300 },
  },
  render: (args) => (
    <Stack {...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>
    </Stack>
  ),
};

Props

NameTypeRequiredDefaultDescription
orientation'horizontal' | 'vertical'No'vertical'

Layout axis of the stack.

gap'none' | 'xs' | 'sm' | 'md' | 'lg' | 'xl'No'md'

Gap size between stack items.

align'start' | 'center' | 'end' | 'stretch'No

Cross-axis alignment of items.

justify'start' | 'center' | 'end' | 'between' | 'around' | 'evenly'No

Main-axis justification of items.

wrapbooleanNo

Whether items should wrap to the next line.

inlinebooleanNo

Whether to use inline-flex instead of flex.

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-stack