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

v3.9 is out.

Layout & primitives

Theme

Free3.8 KB gzipped

Applies 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

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

Light · Blue
Dark · Purple
tsx
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.

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

Blue's own
Lime
#ff9f43
tsx
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.

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

قسم داكن باللون الأرجواني

جديد
tsx
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

Theme props
PropTypeDefault
brand

Brand 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 ("#e11d48") for a custom palette generated in both modes. One hex is used as given in the mode where it meets WCAG AA (dark colors in light mode, light colors in dark mode) and the other mode gets a matching shade; pass { light, dark } to choose both. A color that fails contrast is shifted lighter or darker (same hue) just enough to pass, with a console warning in development.

ThemeBrand | BrandColor—
accentNew in 1.4.10

The 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).

"lime" for the original bright yellow-green, "brand" to go back to the brand's own inside an area with another accent, or any hex color for a custom accent. Accents always carry dark text, so a color too dark for that is lightened (same hue), with a console warning in development. An accent set here also holds inside nested brands.

ThemeAccent | BrandColor—
mode

Color mode for everything inside. Leave unset to inherit.

"light""dark"—
fill

Paint the page background and text color of the theme on this wrapper (useful when mode differs from the page around it).

booleanfalse

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)

Running accessibility audit

Checking the examples above…

Lighthouse audit

Light mode

Score 100

36 passed · 0 failed · 29 not applicable · 10 to check by hand

Dark mode

Score 100

36 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

Roles and states
ElementRoleStates 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.

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)