Layout & primitives
Container
Free0.8 KB gzippedCenters content with a max width and responsive side gutters. Never overflows its parent, so content reflows down to 320px wide.
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 { Container } from "@vjdesigns/vjdesigns-ui";
Importing only Container adds about 0.8 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
Sizes
Centers content at a max width. gutter="responsive" grows the side padding on wider screens.
size="xs"
size="sm"
size="md"
size="lg"
import { Box, Container, Stack, Text } from "@vjdesigns/vjdesigns-ui";
export function Sizes() {
return (
<Stack gap={2} style={{ width: "100%" }}>
{(["xs", "sm", "md", "lg"] as const).map((size) => (
<Container key={size} size={size} gutter={0}>
<Box tone="primary" radius="md" p={3}>
<Text size="sm" weight="semibold" tone="inherit">
size="{size}"
</Text>
</Box>
</Container>
))}
</Stack>
);
}
Prose
size="prose" caps the width at a comfortable line length for reading.
Long lines are tiring to read. Around 60 to 75 characters per line keeps the eye on track from the end of one line to the start of the next, which is what the prose size is tuned for.
import { Container, Text } from "@vjdesigns/vjdesigns-ui";
export function Prose() {
return (
<Container size="prose" gutter={0} style={{ width: "100%" }}>
<Text leading="relaxed">
Long lines are tiring to read. Around 60 to 75 characters per line keeps the eye on track from the end of
one line to the start of the next, which is what the prose size is tuned for.
</Text>
</Container>
);
}
Accessibility
A Container keeps content off the screen edges with gutter and caps line length with size, which keeps long text comfortable to read. Use as="main" (or another landmark) when it wraps a page's main region.
Release notes
Lines this long stay easy to follow because the container stops them from stretching across a wide screen.
import { Box, Container, Stack, Text, Heading } from "@vjdesigns/vjdesigns-ui";
export function Accessibility() {
return (
<Box border radius="lg" style={{ width: "100%" }}>
<Container as="article" size="sm" gutter="responsive" py={6}>
<Stack gap={2}>
<Heading level={3} size="lg">
Release notes
</Heading>
<Text tone="muted">
Lines this long stay easy to follow because the container stops them from stretching across a wide screen.
</Text>
</Stack>
</Container>
</Box>
);
}
Translated
Containers have no text of their own. LocaleProvider sets lang="ja" on the area, so screen readers and fonts use Japanese for the content.
コンテナは行の長さを抑えて、長い文章でも読みやすく保ちます。画面の端に文字が張り付かないよう、左右に余白も確保します。
import { Box, Container, Text, LocaleProvider } from "@vjdesigns/vjdesigns-ui";
import ja from "@vjdesigns/vjdesigns-ui/locales/ja";
export function Translated() {
return (
<LocaleProvider locale="ja" messages={ja}>
<Box border radius="lg" style={{ width: "100%" }}>
<Container size="sm" gutter="responsive" py={6}>
<Text>
コンテナは行の長さを抑えて、長い文章でも読みやすく保ちます。画面の端に文字が張り付かないよう、左右に余白も確保します。
</Text>
</Container>
</Box>
</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.
Sizes
size="xs"
size="sm"
size="md"
size="lg"
import { LocaleProvider } from "@vjdesigns/vjdesigns-ui";
import ar from "@vjdesigns/vjdesigns-ui/locales/ar";
// Sizes is the "Sizes" example above.
<LocaleProvider locale="ar" messages={ar}>
<Sizes />
</LocaleProvider>
API reference
Container
| Prop | Type | Default |
|---|---|---|
asElement to render. Use | "div""main""section""header""footer""article" | — |
sizeMax width of the content: xs 480px, sm 640px, md 768px, lg 1024px, xl 1280px, 2xl 1536px, full 100%, prose 65ch. | "xs""sm""md""lg""xl""2xl""full""prose" | — |
gutterHorizontal padding on both sides. | ContainerGutter | — |
fluidRemoves the max width, keeping only the gutters. Overrides | boolean | — |
centerContentStacks children in a column and centers them horizontally. | boolean | — |
pyVertical padding (top and bottom), as a spacing step. | Space | — |
children | ReactNode | — |
Also accepts standard HTML attributes, plus className, style and ref.
See what changed in each version in the Changelog.
Accessibility report
Container 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 | — |
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) |