Skip to Content
Puzzle

Stack

Arrange elements with token-based spacing and responsive direction.

Import

import { Stack } from "@puzzle-ui/ui";

Direction, alignment, and wrapping

Stack defaults to a column. Alignment maps to CSS properties according to the current direction:

DirectionalignHalignV
colalign-itemsjustify-content
rowjustify-contentalign-items

Resize the preview to see a responsive column become a row.

390 × 400

API

PropTypeDefaultDescription
asElementType"div"Root element.
direction"row" | "col" or responsive object"col"Layout direction.
gap"0" | "xs" | "sm" | "md" | "lg" | "xl""md"Theme spacing scale.
alignH, alignVAxis-dependent alignment-Alignment mapped by direction; see the table above.
wrap"wrap" | "nowrap" | "wrap-reverse""nowrap"Flex wrapping.
reversebooleanfalseReverse visual direction.
dividerReactNode-Content inserted between children.

Main-axis alignment accepts start, center, end, stretch, around, between, evenly; cross-axis alignment accepts start, center, end, stretch. Native props are forwarded. Reversing visual order does not change DOM/keyboard order.

Both alignH and alignV also accept responsive objects, such as alignH={{ mobile: "start", tablet: "center", desktop: "end" }}. Each prop changes independently of direction and inherits its last specified value at larger breakpoints. When direction changes, the mapping to justify-content and align-items changes with it. Distribution values (around, between, evenly) belong to alignH in rows and alignV in columns; use cross-axis values at breakpoints where a prop maps to align-items.

;