Stack
One flexbox primitive for vertical stacks and horizontal rows, with token gaps that shift at each breakpoint.
Install
Install the component
Add the source straight into your project with the shadcn CLI — no package dependency to track.
npx shadcn@latest add https://vert-ui.dev/r/stack.jsonPreview
Live preview
First
Second
Third
Usage
Examples
Responsive row that becomes a column
Alpha
Beta
Gamma
<Stack direction="column" smGap={4} mdGap={6}>
<Block>A</Block>
<Block>B</Block>
</Stack>Form actions
<Stack direction="row" justify="end" gap={2}>
<Button variant="outline">Cancel</Button>
<Button>Save</Button>
</Stack>Vertical metadata list
stablev0.1.0
<Stack gap={1}>
<Badge>stable</Badge>
<span>v0.1.0</span>
</Stack>Reference
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| direction | "row" | "column" | "column" | Main axis. Column stacks vertically, row lays out horizontally. |
| gap | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 8 | 10 | 12 | 4 | Spacing between children on the token scale (gap-*). |
| smGap / mdGap / lgGap | same scale | — | Gap overrides from the sm, md and lg breakpoints up. |
| align | "start" | "center" | "end" | "stretch" | "baseline" | — | Cross-axis alignment (items-*). |
| justify | "start" | "center" | "end" | "between" | "around" | "evenly" | — | Main-axis distribution (justify-*). |
| wrap | boolean | — | Allow children to wrap onto the next line. |
| asChild | boolean | false | Render the child element instead of a div — keeps the styles. |
Accessibility
Accessibility notes
- A plain flex container is not a landmark and adds no semantics — wrap it in the element that matches the content (ul, form, section).
- Because alignment and spacing come from classes, DOM order always matches reading order; visual reordering (row-reverse) is not used.
- Responsive gaps keep related controls close on large screens and comfortably separated on touch screens.