Layout & primitives
Theme
Free3.8 KB gzippedApplies a brand palette, accent, and/or color mode to everything inside it, through data-brand, data-accent, and data-theme (and, for hex colors, the generated custom properties inline). Wrap the whole app, or any part of it; themes nest (a blue area inside a purple app, a dark panel on a light page). Overlays opened inside (Popover, Menu, Modal, Tooltip, Toast, ...) render elsewhere in the page but keep this theme. For the whole page you can instead set the attributes on <html>: <html data-theme="dark" data-brand="purple" data-accent="lime">.
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 { Theme } from "@vjdesigns/vjdesigns-ui";
Importing only Theme adds about 3.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
Scoped
Each Theme sets the mode and brand for everything inside it. fill paints the matching surface.
import { Badge, Button, Flex, Stack, Theme } from "@vjdesigns/vjdesigns-ui";
export function Scoped() {
return (
<Flex gap={4} wrap="wrap" justify="center">
<Theme mode="light" brand="blue" fill style={{ padding: "1.5rem", borderRadius: "var(--radius-lg)" }}>
<Stack gap={3} align="start">
<Badge tone="primary">Light · Blue</Badge>
<Button>Continue</Button>
</Stack>
</Theme>
<Theme mode="dark" brand="purple" fill style={{ padding: "1.5rem", borderRadius: "var(--radius-lg)" }}>
<Stack gap={3} align="start">
<Badge tone="primary">Dark · Purple</Badge>
<Button>Continue</Button>
</Stack>
</Theme>
</Flex>
);
}
Nested
Themes nest. A prop you leave out is inherited from the next theme outward.
Dark, green brand
Still dark: the mode is inherited.
import { Button, Flex, Stack, Text, Theme } from "@vjdesigns/vjdesigns-ui";
export function Nested() {
return (
<Theme mode="dark" brand="green" fill style={{ padding: "1.5rem", borderRadius: "var(--radius-lg)", width: "100%", maxWidth: "26rem" }}>
<Stack gap={4}>
<Text weight="semibold">Dark, green brand</Text>
<Theme brand="gold" fill style={{ padding: "1rem", borderRadius: "var(--radius-md)" }}>
<Flex gap={3} align="center">
<Button size="sm">Gold</Button>
<Text size="sm" tone="muted">
Still dark: the mode is inherited.
</Text>
</Flex>
</Theme>
</Stack>
</Theme>
);
}
Accent
Each brand has its own accent, a brighter shade of its hue, used on badges, switches and progress. accent swaps it: "lime" for the original bright yellow-green, or any hex color.
import { Badge, Flex, Stack, Switch, Theme } from "@vjdesigns/vjdesigns-ui";
export function Accent() {
return (
<Flex gap={4} wrap="wrap" justify="center">
<Theme brand="blue" fill style={{ padding: "1.25rem", borderRadius: "var(--radius-lg)" }}>
<Stack gap={3} align="start">
<Badge tone="accent" variant="solid">Blue's own</Badge>
<Switch label="Alerts" defaultChecked size="sm" />
</Stack>
</Theme>
<Theme brand="blue" accent="lime" fill style={{ padding: "1.25rem", borderRadius: "var(--radius-lg)" }}>
<Stack gap={3} align="start">
<Badge tone="accent" variant="solid">Lime</Badge>
<Switch label="Alerts" defaultChecked size="sm" />
</Stack>
</Theme>
<Theme brand="blue" accent="#ff9f43" fill style={{ padding: "1.25rem", borderRadius: "var(--radius-lg)" }}>
<Stack gap={3} align="start">
<Badge tone="accent" variant="solid">#ff9f43</Badge>
<Switch label="Alerts" defaultChecked size="sm" />
</Stack>
</Theme>
</Flex>
);
}
Accessibility
Every built-in brand passes WCAG 2.2 AA in both modes. A custom hex color that doesn't (this yellow fails on white) is shifted lighter or darker, keeping its hue, just enough to pass, with a console warning in development.
import { Button, Flex, Theme } from "@vjdesigns/vjdesigns-ui";
export function Accessibility() {
return (
<Flex gap={4} wrap="wrap">
<Theme brand="#ffd000" mode="light" fill style={{ padding: "1rem", borderRadius: "0.75rem" }}>
<Button>Light mode</Button>
</Theme>
<Theme brand="#ffd000" mode="dark" fill style={{ padding: "1rem", borderRadius: "0.75rem" }}>
<Button>Dark mode</Button>
</Theme>
</Flex>
);
}
Translated
Theme and language are independent: nest Theme and LocaleProvider in either order. Here a dark, purple section is also in Arabic, so it's right to left.
قسم داكن باللون الأرجواني
import {
Badge,
Button,
Flex,
Stack,
Text,
Theme,
LocaleProvider,
} from "@vjdesigns/vjdesigns-ui";
import ar from "@vjdesigns/vjdesigns-ui/locales/ar";
export function Translated() {
return (
<LocaleProvider locale="ar" messages={ar}>
<Theme brand="purple" mode="dark" fill style={{ padding: "1.25rem", borderRadius: "0.75rem" }}>
<Stack gap={3}>
<Text weight="semibold">قسم داكن باللون الأرجواني</Text>
<Flex gap={2}>
<Button>حفظ</Button>
<Badge tone="primary" variant="soft">
جديد
</Badge>
</Flex>
</Stack>
</Theme>
</LocaleProvider>
);
}
API reference
Theme
| Prop | Type | Default |
|---|---|---|
brandBrand palette for everything inside: buttons, links, focus rings, selection, and indicators all switch at once. Leave unset to inherit. A preset name, or any hex color ( | ThemeBrand | BrandColor | — |
accentNew in 1.4.10The accent: the energetic highlight on badges, switches, progress bars, sliders, steppers, and active navigation. Leave unset to inherit; with no accent set anywhere, each brand uses its own (a bright shade of its hue).
| ThemeAccent | BrandColor | — |
modeColor mode for everything inside. Leave unset to inherit. | "light""dark" | — |
fillPaint the page background and text color of the theme on this wrapper (useful when | boolean | false |
Also accepts native <div> attributes, plus className, style and ref.
See what changed in each version in the Changelog.
Accessibility report
Theme 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 10036 passed · 0 failed · 29 not applicable · 10 to check by hand
Dark mode
Score 10036 passed · 0 failed · 29 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 |
|---|---|---|
Wrapper <div> | none (generic) | data-theme, data-brand and data-accent only; nothing is announced |
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) |