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.
Import this stylesheet once, before any other app or component module, from your application entry point — see Installation for why import order and placement matter.
If you're starting from ui-lab-theme-onyx instead of a fully app-owned theme, import it right after tailwindcss and before your own theme.css:
Foundational token contract
A fully app-owned theme.css (no ui-lab-theme-onyx import) must define every token component CSS reads, not just colors. Some foundational tokens — like --border-width-base — are read directly by component CSS without a fallback. Leaving one undefined can make the dependent property compute to an invalid value, which is different from "wrong color": it can render as a missing border or a square corner where a rounded one was expected.
ui-lab-theme-onyx already defines the foundational token contract, so apps that import it don't need to repeat this.
How the token pipeline works
Color families
Each family has a bounded shade range:
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
Troubleshooting
Broadly incorrect / reset-looking component styles
Symptom: components look unstyled or reset, as if Tailwind's base styles won over UI Lab's. Cause: CSS cascade layers registered in the wrong order — the global stylesheet was imported after an app/component module instead of before it, or ui-lab-theme-onyx / theme.css / ui-lab-components/styles.css were imported out of order. See Installation for the required order and entry-point placement.
Square Switch thumbs / invalid computed styles
Symptom: a component that should render with rounded corners (Switch's thumb is the most visible case) renders square, or a border is missing. Cause: a foundational token — most commonly --border-width-base — isn't defined by your theme.css. See Foundational token contract above.
Further reading
- Installation — stylesheet setup and import order
- 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