Stack
Status: stableAccessibility reviewedtenet-ui@0.4.0
import { Stack } from 'tenet-ui';Also accepts every prop of HTMLAttributes<HTMLDivElement>.
Source: src/components/Stack/Stack.tsx
Usage guidelines
Section titled “Usage guidelines”When to use: any time you place two or more elements next to or above each other with space between them. Stack is the design-system layout primitive — reach for it instead of writing display: flex with hardcoded gaps, and instead of reinventing a generic Box.
- Use
directionfor the axis andgapfor spacing —gapvalues map to thespacescale (condensed=8,normal=16,spacious=24). Never set a pixel gap or margins between Stack children. - Use
Stack.Item growfor the child that should absorb extra space (e.g. a search field in a toolbar) rather thanflex: 1inline. - Use
align/justifyfor alignment; don’t add wrapper<div>s just to center things. padding(optional) also comes from thespacescale.Stackis one axis. For columns (tiles, side-by-side fields) useGridwithcolumnsandGrid.Item span; it shares the samegapscale.
Do / Don’t
Section titled “Do / Don’t”- ✅
<Stack direction="horizontal" gap="condensed" align="center">…</Stack> - ✅
<Stack.Item grow><TextInput … /></Stack.Item> - ❌
<div style={{ display: 'flex', gap: 12 }}>— raw flex, hardcoded gap. - ❌ A bespoke
Boxcomponent that re-implements spacing with a customsxprop.
See also: Grid for columns and responsive layouts; system guideline layout (gap scale, breakpoints, Card vs plain section).
Examples
Section titled “Examples”3 stories for Stack — open in Storybook
- Vertical
components-stack--vertical - Horizontal
components-stack--horizontal - Toolbar
components-stack--toolbar
The full matrix (all args, controls, accessibility panel) is in Storybook.
Stack
| Prop | Type | Default | Description |
|---|---|---|---|
direction | 'horizontal' | 'vertical'StackDirection | vertical | Main-axis direction. |
gap | 'none' | 'condensed' | 'normal' | 'spacious'StackGap | normal | Space between children, from the space scale (condensed=8, normal=16, spacious=24). |
align | 'start' | 'center' | 'end' | 'stretch'StackAlign | — | Cross-axis alignment (maps to align-items). |
justify | 'start' | 'center' | 'end' | 'between'StackJustify | — | Main-axis distribution (maps to justify-content). |
wrap | boolean | false | Allow children to wrap onto multiple lines. |
padding | 'none' | 'condensed' | 'normal' | 'spacious'StackPadding | — | Inner padding, from the space scale. |
children | ReactNode | — |
Stack.Item
| Prop | Type | Default | Description |
|---|---|---|---|
grow | boolean | false | Grow to fill the available space along the main axis. |
children | ReactNode | — |