Skip to content
Vertical Jump Designs-uiFront-End Studio
Get Pro

v3.9 is out.

Layout & primitives

Stack

Free1.7 KB gzipped

One-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

tsx
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

tsx
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

tsx
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

tsx
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.

账户


账单


退出登录

tsx
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

tsx
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

Stack props
PropTypeDefault
as

Element to render. Native props are typed for the chosen element. ul/ol drop bullets and padding but keep list semantics.

StackElement—
direction

Main-axis direction. Responsive: { base: "column", md: "row" }. Reverse directions change visual order only; DOM, reading, and focus order stay the same.

Responsive<StackDirection>—
gap

Space between children, as a step on the --space-* scale. Responsive.

Responsive<Space>—
align

Cross-axis alignment of children. Responsive.

Responsive<StackAlign>—
justify

Main-axis distribution of children. Responsive.

Responsive<StackJustify>—
wrap

Let children wrap onto multiple lines. Responsive. Rows don't wrap by default: use wrap, a responsive direction, or stackBelow for rows that must reflow at 320px (SC 1.4.10).

Responsive<boolean>—
divider

Inserted between every pair of children. Pass true for the built-in token-styled line (see dividerSemantics), or any node for a custom divider (you own its semantics). In ul/ol stacks, dividers are wrapped in an aria-hidden <li> so the list stays valid and item counts stay correct.

ReactNode—
dividerSemantics

Accessibility semantics of the built-in divider. Ignored for custom dividers and in list stacks (always decorative there). A separator stays decorative when stackBelow is set or direction is responsive, since its orientation flips at a breakpoint.

"decorative""separator"—
fullWidth

Stretch to the full inline size of the container.

boolean—
stackBelow

Switch a row/row-reverse stack to a column below this breakpoint. Has no effect on column stacks or with a responsive direction (which covers this: { base: "column", md: "row" }).

"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)

Running accessibility audit

Checking the examples above…

Lighthouse audit

Light mode

Score 100

35 passed · 0 failed · 30 not applicable · 10 to check by hand

Dark mode

Score 100

35 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

Roles and states
ElementRoleStates and properties
<div>, or the element in asNative role of that element—
divider between itemsseparatoraria-orientation

Manual checks

Automated tools find roughly a third of accessibility issues. Test these in your app, with your content.

Manual accessibility checks
CheckWhat to testWCAG 2.2
KeyboardEvery 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)
FocusFocus 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 readersNames, 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)
ColorMeaning 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 reflowAt 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 targetsClick 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)
MotionAnimations respect the reduced-motion setting.2.3.3 (AAA)