Layout & primitives
Stack
Free1.7 KB gzippedOne-dimensional flex layout. Lays children out in a column (default) or row with token-based gaps, optional dividers, and an optional responsive switch from row to column.
Accessibility: WCAG 2.2 AA · No A or AA violations in light or dark mode · No keyboard interaction of its own · Full report
Import
import { Stack } from "@vjdesigns/vjdesigns-ui";
Importing only Stack adds about 1.7 KB of minified, gzipped JavaScript to your app (React not included). The stylesheet is shared by every component and loaded once: 75.1 KB gzipped.
Examples
With dividers
One-direction layout with consistent spacing. divider goes between every child.
Account
Notifications
Privacy
import { Divider, Stack, Text } from "@vjdesigns/vjdesigns-ui";
export function WithDividers() {
return (
<Stack gap={3} divider={<Divider />} style={{ width: "100%", maxWidth: "22rem" }}>
<Text>Account</Text>
<Text>Notifications</Text>
<Text>Privacy</Text>
</Stack>
);
}
Row that stacks
stackBelow stacks a row vertically under a breakpoint, a common pattern for cards and forms.
Plan
Build
Ship
import { Box, Stack, Text } from "@vjdesigns/vjdesigns-ui";
export function RowThatStacks() {
return (
<Stack direction="row" stackBelow="md" gap={4} style={{ width: "100%" }}>
{["Plan", "Build", "Ship"].map((step) => (
<Box key={step} tone="primary" radius="md" p={4} style={{ flex: 1 }}>
<Text weight="semibold" tone="inherit">
{step}
</Text>
</Box>
))}
</Stack>
);
}
Accessibility
Dividers between items are decorative by default. Use dividerSemantics="separator" when the line marks a real break between groups, so screen readers announce a separator there too.
Account
Billing
Sign out
import { Divider, Stack, Text } from "@vjdesigns/vjdesigns-ui";
export function Accessibility() {
return (
<Stack gap={3} divider={<Divider />} dividerSemantics="separator" style={{ width: "100%", maxWidth: "22rem" }}>
<Text>Account</Text>
<Text>Billing</Text>
<Text>Sign out</Text>
</Stack>
);
}
Translated
Stacks have no text of their own; LocaleProvider sets lang, so screen readers read the content in Chinese. A row stack (direction="row") runs right to left in RTL locales.
账户
账单
退出登录
import { Divider, Stack, Text, LocaleProvider } from "@vjdesigns/vjdesigns-ui";
import zhHans from "@vjdesigns/vjdesigns-ui/locales/zh-Hans";
export function Translated() {
return (
<LocaleProvider locale="zh-Hans" messages={zhHans}>
<Stack gap={3} divider={<Divider />} style={{ width: "100%", maxWidth: "22rem" }}>
<Text>账户</Text>
<Text>账单</Text>
<Text>退出登录</Text>
</Stack>
</LocaleProvider>
);
}
Right to left
The first example again, inside a right-to-left LocaleProvider (Arabic). Layout, spacing and arrow icons mirror, and the components' built-in text is translated. The example's own text stays in English.
With dividers
Account
Notifications
Privacy
import { LocaleProvider } from "@vjdesigns/vjdesigns-ui";
import ar from "@vjdesigns/vjdesigns-ui/locales/ar";
// WithDividers is the "With dividers" example above.
<LocaleProvider locale="ar" messages={ar}>
<WithDividers />
</LocaleProvider>
API reference
Stack
| Prop | Type | Default |
|---|---|---|
asElement to render. Native props are typed for the chosen element. | StackElement | — |
directionMain-axis direction. Responsive: | Responsive<StackDirection> | — |
gapSpace between children, as a step on the | Responsive<Space> | — |
alignCross-axis alignment of children. Responsive. | Responsive<StackAlign> | — |
justifyMain-axis distribution of children. Responsive. | Responsive<StackJustify> | — |
wrapLet children wrap onto multiple lines. Responsive. Rows don't wrap by default: use | Responsive<boolean> | — |
dividerInserted between every pair of children. Pass | ReactNode | — |
dividerSemanticsAccessibility semantics of the built-in divider. Ignored for custom dividers and in list stacks (always decorative there). A | "decorative""separator" | — |
fullWidthStretch to the full inline size of the container. | boolean | — |
stackBelowSwitch a | "sm""md""lg" | — |
Also accepts standard HTML attributes, plus className, style and ref.
See what changed in each version in the Changelog.
Accessibility report
Stack targets WCAG 2.2 AA. Below: a live axe-core audit of this page's examples, Lighthouse scores for the page in both modes, the accessibility behavior built into the component, and the checks only a person can do.
axe-core audit (live)
Checking the examples above…
Lighthouse audit
Light mode
Score 10035 passed · 0 failed · 30 not applicable · 10 to check by hand
Dark mode
Score 10035 passed · 0 failed · 30 not applicable · 10 to check by hand
Lighthouse 13.5.0 audits the whole docs page (header and sidebar included), not just the examples, in English. Last run 11/27/2026. Some failed audits carry no weight in the score, so a page can score 100 and still list one.
Built-in behavior
Keyboard
Not focusable, so there's no keyboard interaction of its own.
Roles and states
| Element | Role | States and properties |
|---|---|---|
<div>, or the element in as | Native role of that element | — |
divider between items | separator | aria-orientation |
Manual checks
Automated tools find roughly a third of accessibility issues. Test these in your app, with your content.
| Check | What to test | WCAG 2.2 |
|---|---|---|
| Keyboard | Every action works with Tab, Shift+Tab, Enter, Space and the arrow keys, and focus never gets stuck. | 2.1.1 (A), 2.1.2 (A) |
| Focus | Focus moves in a logical order, is always visible, and isn't hidden behind sticky headers. | 2.4.3 (A), 2.4.7 (AA), 2.4.11 (AA), 2.4.13 (AAA) |
| Screen readers | Names, roles and states are announced correctly, and status changes are announced without moving focus. | 1.3.1 (A), 4.1.2 (A), 4.1.3 (AA) |
| Color | Meaning never depends on color alone; your own colors meet contrast in both modes. | 1.4.1 (A), 1.4.3 (AA), 1.4.11 (AA), 1.4.6 (AAA) |
| Zoom and reflow | At 200% text size and at 320px wide (400% zoom), nothing is cut off and no sideways scrolling is needed. | 1.4.4 (AA), 1.4.10 (AA), 1.4.12 (AA) |
| Pointer targets | Click and tap targets are at least 24×24px (44×44px for AAA), or spaced so they don't overlap. | 2.5.8 (AA), 2.5.5 (AAA) |
| Motion | Animations respect the reduced-motion setting. | 2.3.3 (AAA) |