Ask Rift AI
Theme: Smoke
Layout: Contained
Background: Field
Search or ask anythingAsk Rift AI
Theme: Smoke
Layout: Contained
Background: Field
Colour mode: System

Stack

One direction, one gap

Stack lays its children out in a column or a row with a gap from the scale between them, so the space in a page, a panel or a form comes from the system rather than from a margin on each piece. It adds no semantics of its own: render it as a list, a section or a form when it is one.

Column

Account details

Notifications

Billing

Row, spread to the ends

Equal heights

A short card.

A card with more to say, running over several lines, sets the height for the cards beside it.

Another short one.

Alternatives

  • Use Grid instead when the children should sit in equal columns that fold by the room the grid has.

Props

Read from the same JSDoc that ships in the package's types. A required prop is marked with an asterisk.

Stack props
PropTypeDefaultDescription
direction
"row" | "column"
'column'
`column` lays the children top to bottom; `row` lays them in the reading direction.
gap
StackGap
'400'
The space between children, as a step on the gap scale (`--gap-400` by default).
align
"center" | "start" | "end" | "baseline" | "stretch"
'stretch' in a column, 'center' in a row
How children line up across the stack: `stretch` fills it, which keeps cards in a row the same height. A column stretches and a row centres unless it is set.
justify
"center" | "start" | "end" | "between"
'start'
How children spread along the stack. `between` pushes the first and last to the ends.
wrap
boolean
false
Lets a row wrap onto more lines when it runs out of room, keeping the gap between lines.
as
"div" | "fieldset" | "footer" | "form" | "header" | "li" | "nav" | "ol" | "section" | "span" | "ul"
'div'
The element the stack renders as, so it can be a list, a section or a form.
children
ReactNode
The stack's children.
className
string
''
Additional CSS classes

Keys

Nothing here takes focus, so there are no keys. A test holds that.

tsx
// From the npm package
import { Stack } from 'rift-ds/components/Stack/Stack';

// Or as source you own, via the shadcn CLI
npx shadcn@latest add https://rift-ds.com/r/stack.json

0.3 kB gzipped, with everything it imports. Peer dependencies are not counted.

For agents: the props, their allowed values and defaults, and the tested keys, as markdown or as a JSON schema.