Layout & primitives
Grid
Free1.3 KB gzippedA 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
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
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
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
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.
ראשון
שני
שלישי
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
| Prop | Type | Default |
|---|---|---|
columnsColumn tracks. A number makes that many equal columns ( | Responsive<number | string> | — |
minItemWidthBuilds a responsive grid without media queries: as many columns as fit, each at least this wide (any CSS length, e.g. | string | — |
rowsRow tracks. A number makes that many equal rows; a string is a raw | Responsive<number | string> | — |
autoRowsSize of implicitly created rows ( | string | — |
gapSpace between rows and columns. Maps to | Responsive<Space> | — |
rowGapSpace between rows. Overrides | Responsive<Space> | — |
columnGapSpace between columns. Overrides | Responsive<Space> | — |
alignBlock-axis alignment of items within their cells ( | "start""center""end""stretch""baseline" | — |
justifyInline-axis alignment of items within their cells ( | "start""center""end""stretch" | — |
flowAuto-placement direction ( Accessibility: | "row""column""dense""row dense""column dense" | — |
inlineRender as | boolean | — |
classNameAdditional class names, merged with the component's own. | string | — |
styleInline styles, merged after the grid's custom properties. | CSSProperties | — |
children | ReactNode | — |
asElement 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).
| Prop | Type | Default |
|---|---|---|
colSpanNumber of columns to span, or | Responsive<number | "full"> | — |
rowSpanNumber of rows to span. Responsive. | Responsive<number> | — |
colStartColumn line to start at. See the accessibility note on | GridLine | — |
colEndColumn line to end at. | GridLine | — |
rowStartRow line to start at. | GridLine | — |
rowEndRow line to end at. | GridLine | — |
classNameAdditional class names, merged with the component's own. | string | — |
styleInline styles, merged after the item's custom properties. | CSSProperties | — |
children | ReactNode | — |
asElement 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)
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 | role="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.
| 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) |