vert-ui
Browse docs
All components

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.json

Preview

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

PropTypeDefaultDescription
direction"row" | "column""column"Main axis. Column stacks vertically, row lays out horizontally.
gap0 | 1 | 2 | 3 | 4 | 5 | 6 | 8 | 10 | 124Spacing between children on the token scale (gap-*).
smGap / mdGap / lgGapsame 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-*).
wrapboolean—Allow children to wrap onto the next line.
asChildbooleanfalseRender 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.