Stack
Flex container for arranging children in a line with consistent spacing.
Layout props (direction, align, justify, gap) accept a single value or a
per-breakpoint responsive object like { base: "column", md: "row" }; set responsiveMode
to "container" to resolve breakpoints against the nearest container instead of the viewport.
Stacks vertically by default.
Usage
import { HStack, Stack, StackProps, VStack } from "@desk/ui/components/stack";Best practices
Stackis a gapped one-axis line, vertical by default — useHStack/VStackto lock direction; for full flexbox control (justify/wrap) reach forFlex.asandasChildare mutually exclusive (asChildwins, dev-warned);asdraws from the closed layout vocabulary, soas="button"is a type error (useButton).
Props
HStack
| Prop | Type | Default | Description |
|---|---|---|---|
| asChild | boolean | false | Merge props onto the single child element instead of rendering a div. |
| gap | ResponsiveValue<"base" | "none" | "2xs" | "xs" | "sm" | "lg" | "xl" | "2xl" | "3xl" | "3xs"> | "base" | Gap between items, from the spacing scale. Accepts a per-breakpoint responsive object. |
| align | ResponsiveValue<FlexAlign> | "stretch" | Cross-axis alignment. Accepts a per-breakpoint responsive object. |
| justify | ResponsiveValue<FlexJustify> | "flex-start" | Main-axis distribution. Accepts a per-breakpoint responsive object. |
| responsiveMode | ResponsiveMode | "screen" | Whether responsive values resolve against the viewport ("screen") or nearest container ("container"). |
| as | "div" | "li" | "nav" | "ol" | "span" | "ul" | "article" | "aside" | "figcaption" | "figure" | "footer" | "header" | "main" | "section" | Render as a different host element from the closed layout vocabulary
({@link LayoutElement}). The set is deliberately closed: | |
| guidelines | boolean | false | Show dashed outline guidelines during development. |
Stack
| Prop | Type | Default | Description |
|---|---|---|---|
| align | ResponsiveValue<FlexAlign> | "stretch" | Cross-axis alignment. Accepts a per-breakpoint responsive object. |
| as | "div" | "li" | "nav" | "ol" | "span" | "ul" | "article" | "aside" | "figcaption" | "figure" | "footer" | "header" | "main" | "section" | Render as a different host element from the closed layout vocabulary
({@link LayoutElement}). The set is deliberately closed: | |
| asChild | boolean | false | Merge props onto the single child element instead of rendering a div. |
| direction | ResponsiveValue<FlexDirection> | "column" | Main-axis direction. Accepts a per-breakpoint responsive object. |
| gap | ResponsiveValue<"base" | "none" | "2xs" | "xs" | "sm" | "lg" | "xl" | "2xl" | "3xl" | "3xs"> | "base" | Gap between items, from the spacing scale. Accepts a per-breakpoint responsive object. |
| guidelines | boolean | false | Show dashed outline guidelines during development. |
| justify | ResponsiveValue<FlexJustify> | "flex-start" | Main-axis distribution. Accepts a per-breakpoint responsive object. |
| responsiveMode | ResponsiveMode | "screen" | Whether responsive values resolve against the viewport ("screen") or nearest container ("container"). |
VStack
| Prop | Type | Default | Description |
|---|---|---|---|
| asChild | boolean | false | Merge props onto the single child element instead of rendering a div. |
| gap | ResponsiveValue<"base" | "none" | "2xs" | "xs" | "sm" | "lg" | "xl" | "2xl" | "3xl" | "3xs"> | "base" | Gap between items, from the spacing scale. Accepts a per-breakpoint responsive object. |
| align | ResponsiveValue<FlexAlign> | "stretch" | Cross-axis alignment. Accepts a per-breakpoint responsive object. |
| justify | ResponsiveValue<FlexJustify> | "flex-start" | Main-axis distribution. Accepts a per-breakpoint responsive object. |
| responsiveMode | ResponsiveMode | "screen" | Whether responsive values resolve against the viewport ("screen") or nearest container ("container"). |
| as | "div" | "li" | "nav" | "ol" | "span" | "ul" | "article" | "aside" | "figcaption" | "figure" | "footer" | "header" | "main" | "section" | Render as a different host element from the closed layout vocabulary
({@link LayoutElement}). The set is deliberately closed: | |
| guidelines | boolean | false | Show dashed outline guidelines during development. |
Also exports
- interface
StackProps