Theming

How UI Lab's token system works — color families, shade ranges, dark mode inversion, and dynamic accent customization.

Theming

UI Lab is built on a semantic token system backed by OKLCH — a perceptually-uniform color space. Every color decision routes through CSS custom properties, so swapping themes or customizing the accent is a one-line change.

Consumers usually own the token layer in their app's theme.css. With Tailwind v4, the normal setup is:

theme.css defines your app tokens and mode rules. ui-lab-components/styles.css consumes those active --color-* tokens. You do not need a tailwind.config.ts content extension step for this integration.

How the token pipeline works

Color families

Each family has a bounded shade range:

FamilyShade rangeDirectionUse for
background500–950500 = lightest surfacePage, card, container backgrounds
foreground50–40050 = lightest textText, borders, icons, labels
accent50–600600 = strongestPrimary actions, CTAs, links
success50–600600 = strongestConfirmations, positive states
danger50–600600 = strongestErrors, destructive actions
warning50–600600 = strongestCautions, pending states
info50–600600 = strongestNeutral information

Dark mode inversion

There is no dark: prefix in UI Lab. Shades invert automatically when the theme switches:

Applying tokens

To make Tailwind utilities point at your live token values, map them in @theme inline inside your app-owned theme.css:

Tailwind classes

CSS variables

Customizing the accent color

The accent family is designed for dynamic customization. Override it in your app-owned theme.css:

All components that use accent-* tokens pick up the change automatically — no component code changes needed.

Common mistakes

WrongCorrect
bg-whitebg-background-500
text-gray-900text-foreground-400
bg-zinc-100bg-background-600
bg-background-50bg-background-500 — min shade is 500
text-foreground-500text-foreground-400 — max shade is 400
bg-accent-700bg-accent-600 — max shade is 600
border-red-500border-danger-500

Further reading

  • Colors — full OKLCH palette reference with all shade values
  • Design Tokens — complete token reference for spacing, typography, and motion
  • Variables — all CSS custom properties and their defaults