<Stack direction="row" gap={2} align="start" justify="start">
<Placeholder>1</Placeholder>
<Placeholder>2</Placeholder>
<Placeholder>3</Placeholder>
</Stack>Features
- Arranges children in rows or columns.
- Supports responsive direction, alignment, spacing, and wrapping.
- Grows, spaces, and sizes items with
Stack.Item. - Adds dividers between children.
- Renders strings and numbers as
Text.
Direction
Stack is a column by default. Set direction to row, or reverse either direction.
<Stack direction="row" gap={2}>
<Placeholder>1</Placeholder>
<Placeholder>2</Placeholder>
<Placeholder>3</Placeholder>
</Stack>
<Stack direction="row-reverse" gap={2}>
<Placeholder>1</Placeholder>
<Placeholder>2</Placeholder>
<Placeholder>3</Placeholder>
</Stack>Responsive Direction
Pass a breakpoint object to change the layout with the window width.
<Stack direction={{ xs: "column", md: "row" }} gap={{ xs: 2, md: 4 }}>
<Placeholder>1</Placeholder>
<Placeholder>2</Placeholder>
<Placeholder>3</Placeholder>
</Stack>Alignment
align positions items on the cross axis and justify on the main axis. Row directions align to start by default.
<Stack align="center" gap={2}>
<Placeholder>Short</Placeholder>
<Placeholder>A longer item</Placeholder>
</Stack>
<Stack direction="row" justify="space-between">
<Placeholder>Start</Placeholder>
<Placeholder>End</Placeholder>
</Stack>Wrapping
Row directions wrap by default unless an item grows. Set wrap={false} to keep items on one line.
<Stack direction="row" gap={2} maxWidth={200}>
<Placeholder>One</Placeholder>
<Placeholder>Two</Placeholder>
<Placeholder>Three</Placeholder>
<Placeholder>Four</Placeholder>
</Stack>
<Stack direction="row" gap={2} maxWidth={200} wrap={false} overflow="hidden">
<Placeholder>One</Placeholder>
<Placeholder>Two</Placeholder>
<Placeholder>Three</Placeholder>
<Placeholder>Four</Placeholder>
</Stack>Spacing and Surfaces
Spacing props use 4pt units. Combine padding, background, border, radius, and shadow props to build surfaces such as cards and list rows.
<Stack backgroundColor="surface" borderColor="default" borderRadius="md" padding={4} gap={1}>
<Text weight="medium">Card title</Text>
<Text size="body-sm" color="subtle">Card description</Text>
</Stack>
<Stack backgroundColor="default" borderRadius="md" padding={4} shadow="md">
<Text>Elevated</Text>
</Stack>Flexible Items
Wrap a child in Stack.Item to let it grow into the free space, or to set the gap before it. gapBefore="auto" pushes the item to the end.
<Stack direction="row" gap={2}>
<Placeholder>Fixed</Placeholder>
<Stack.Item grow>
<Placeholder>Grows to fill the row</Placeholder>
</Stack.Item>
</Stack>
<Stack direction="row" gap={2}>
<Placeholder>Start</Placeholder>
<Placeholder>Start</Placeholder>
<Stack.Item gapBefore="auto">
<Placeholder>End</Placeholder>
</Stack.Item>
</Stack>Columns
Stack.Item columns spans part of a 12-column row, as on web. The stack measures its width first, so the width settles after the first layout; for grids, use Columns.
<Stack direction="row" gap={2}>
<Stack.Item columns={{ xs: 12, sm: 6 }}>
<Placeholder>Full on phones</Placeholder>
</Stack.Item>
<Stack.Item columns={{ xs: 12, sm: 6 }}>
<Placeholder>Half from 600</Placeholder>
</Stack.Item>
</Stack>Text Alignment
textAlign sets the default alignment of Vortex Text inside the stack, including nested stacks.
<Stack textAlign="center" gap={1}>
<Text weight="medium">Title</Text>
<Text size="body-sm" color="subtle">
Nested Text follows the stack alignment.
</Text>
</Stack>Dividers
Set divider to render a Divider between children.
<Stack gap={3} divider>
<Text>Account</Text>
<Text>Notifications</Text>
<Text>Privacy</Text>
</Stack>
<Stack direction="row" gap={3} divider>
<Text>Edit</Text>
<Text>Share</Text>
<Text>Delete</Text>
</Stack>Accessibility
View and adds no role. Pass role or other accessibility props through attributes when the content is a group or list.