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

v3.9 is out.

Layout & primitives

Grid

Free1.3 KB gzipped

A CSS grid container.

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 { Grid } from "@vjdesigns/vjdesigns-ui";

Importing only Grid adds about 1.3 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

Responsive

columns takes a number or one per breakpoint. Grid.Item spans columns and rows.

Featured

1

2

3

4

tsx
import { Box, Grid, Text } from "@vjdesigns/vjdesigns-ui";

export function Responsive() {
  return (
    <Grid columns={{ base: 2, md: 4 }} gap={3} style={{ width: "100%" }}>
      <Grid.Item colSpan={{ base: "full", md: 2 }} rowSpan={2}>
        <Box tone="primary" radius="md" p={4} style={{ height: "100%" }}>
          <Text weight="semibold" tone="inherit">
            Featured
          </Text>
        </Box>
      </Grid.Item>
      {[1, 2, 3, 4].map((n) => (
        <Box key={n} tone="neutral" radius="md" p={4}>
          <Text weight="semibold" tone="inherit">
            {n}
          </Text>
        </Box>
      ))}
    </Grid>
  );
}

Auto fit

minItemWidth fits as many columns as there's room for, with no breakpoints needed.

Item 1

Item 2

Item 3

Item 4

Item 5

Item 6

Item 7

Item 8

tsx
import { Box, Grid, Text } from "@vjdesigns/vjdesigns-ui";

export function AutoFit() {
  return (
    <Grid minItemWidth="8rem" gap={3} style={{ width: "100%" }}>
      {Array.from({ length: 8 }, (_, i) => (
        <Box key={i} tone="accent" radius="md" p={4} textAlign="center">
          <Text weight="semibold" tone="inherit">
            Item {i + 1}
          </Text>
        </Box>
      ))}
    </Grid>
  );
}

Accessibility

minItemWidth fits as many columns as there's room for and drops to one column on a narrow screen, so content reflows at 320px without sideways scrolling (SC 1.4.10). The source order is the reading order, row by row.

Plan

Seats

Storage

Support

tsx
import { Box, Grid, Text } from "@vjdesigns/vjdesigns-ui";

export function Accessibility() {
  return (
    <Grid minItemWidth="10rem" gap={3} style={{ width: "100%" }}>
      {["Plan", "Seats", "Storage", "Support"].map((label) => (
        <Box key={label} surface="raised" border radius="md" p={4}>
          <Text weight="semibold">{label}</Text>
        </Box>
      ))}
    </Grid>
  );
}

Translated

In Hebrew the grid fills from the right, so the first item is in the top-right corner. Reading order still follows the source.

ראשון

שני

שלישי

tsx
import { Box, Grid, Text, LocaleProvider } from "@vjdesigns/vjdesigns-ui";
import he from "@vjdesigns/vjdesigns-ui/locales/he";

export function Translated() {
  return (
    <LocaleProvider locale="he" messages={he}>
      <Grid columns={{ base: 1, sm: 3 }} gap={3} style={{ width: "100%" }}>
        {["ראשון", "שני", "שלישי"].map((label) => (
          <Box key={label} surface="raised" border radius="md" p={4}>
            <Text weight="semibold">{label}</Text>
          </Box>
        ))}
      </Grid>
    </LocaleProvider>
  );
}

Usage notes

Use columns for a fixed or breakpoint-driven column count, or minItemWidth for an intrinsic grid that fits as many columns as the container allows. Place children with Grid.Item.

Accessibility: Grid is purely presentational and adds no role. The reading and focus order is always the DOM order, so keep the source order meaningful. Visual reordering with flow="dense" or explicit placement on Grid.Item must not make the visual order contradict the reading or focus order (WCAG 1.3.2, 2.4.3). When rendering a list (as="ul") and removing bullets, add role="list" so Safari/VoiceOver keeps list semantics.

API reference

Grid

Grid props
PropTypeDefault
columns

Column tracks. A number makes that many equal columns (repeat(n, minmax(0, 1fr))); a string is used as a raw grid-template-columns value (e.g. "16rem 1fr"). Accepts a responsive object: { base: 1, md: 2, lg: 4 }. Ignored when minItemWidth is set. A fixed number never collapses, so for content that must reflow at 320px (SC 1.4.10) start at base: 1 or use minItemWidth.

Responsive<number | string>—
minItemWidth

Builds a responsive grid without media queries: as many columns as fit, each at least this wide (any CSS length, e.g. "14rem"). Never wider than the container, so it reflows to one column on narrow screens (WCAG 1.4.10). Takes precedence over columns.

string—
rows

Row tracks. A number makes that many equal rows; a string is a raw grid-template-rows value. Responsive.

Responsive<number | string>—
autoRows

Size of implicitly created rows (grid-auto-rows), e.g. "8rem" or "minmax(8rem, auto)".

string—
gap

Space between rows and columns. Maps to --space-*. Responsive.

Responsive<Space>—
rowGap

Space between rows. Overrides gap for rows. Responsive.

Responsive<Space>—
columnGap

Space between columns. Overrides gap for columns. Responsive.

Responsive<Space>—
align

Block-axis alignment of items within their cells (align-items).

"start""center""end""stretch""baseline"—
justify

Inline-axis alignment of items within their cells (justify-items).

"start""center""end""stretch"—
flow

Auto-placement direction (grid-auto-flow).

Accessibility: dense back-fills holes, so items can appear visually out of source order. Screen readers and keyboard focus follow the DOM order, so only use dense packing when order carries no meaning (WCAG 1.3.2 Meaningful Sequence, 2.4.3 Focus Order).

"row""column""dense""row dense""column dense"—
inline

Render as inline-grid instead of grid.

boolean—
className

Additional class names, merged with the component's own.

string—
style

Inline styles, merged after the grid's custom properties.

CSSProperties—
childrenReactNode—
as

Element or component to render as. Native props are typed for it.

ElementType—

Grid.Item

A child of Grid with span and placement controls. Any element can be a grid child; use Grid.Item only when you need spans or placement.

Accessibility: explicit placement (colStart, rowStart, ...) moves items visually without changing the DOM order that screen readers and the Tab key follow. Keep the visual order consistent with the source order (WCAG 1.3.2 Meaningful Sequence, 2.4.3 Focus Order).

Grid.Item props
PropTypeDefault
colSpan

Number of columns to span, or "full" to stretch across every column (1 / -1). Responsive: { base: "full", md: 2 }.

Responsive<number | "full">—
rowSpan

Number of rows to span. Responsive.

Responsive<number>—
colStart

Column line to start at. See the accessibility note on Grid.Item about explicit placement.

GridLine—
colEnd

Column line to end at.

GridLine—
rowStart

Row line to start at.

GridLine—
rowEnd

Row line to end at.

GridLine—
className

Additional class names, merged with the component's own.

string—
style

Inline styles, merged after the item's custom properties.

CSSProperties—
childrenReactNode—
as

Element or component to render as. Native props are typed for it.

ElementType—

See what changed in each version in the Changelog.

Accessibility report

Grid 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 elementrole="list" when rendered as a list

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)