theming
Giving the same components different looks, such as light, dark or a different brand, by swapping the token values they use.
In more detail
Good theming never edits components: it changes which values the semantic tokens point to. On the web this is usually done by redefining CSS custom properties under a selector such as [data-theme="dark"]. Themes can be nested, so one section of a page can use a different theme from the rest.
Example
In the browser: A clean approach sets design tokens as custom properties on :root and swaps them with a data-theme attribute or a prefers-color-scheme media query. Components only reference the tokens, so they follow the theme automatically.Related terms
- semantic token — A token named for its purpose, such as color.action.bg or color.surface, that points at a global token.
- CSS custom property — A value you name yourself in CSS, such as --color-primary: #2563eb, and use elsewhere with var(--color-primary).
- data attribute — A custom HTML attribute whose name starts with data-, such as data-theme="dark", used to store extra information on an element.
- dark mode — A colour theme with light text on dark backgrounds, offered alongside the usual light theme.
- CSS custom property — A property you define yourself with a double-hyphen name, such as --brand: #0066cc, and read elsewhere with var(--brand).
- design token — A named design decision, such as a colour, font size or spacing value, stored as data so every platform can use the same value.
- prefers-color-scheme — The CSS media feature that reports whether the user has asked their operating system for a light or dark appearance.
Taught in
- Design Tokens: W3C Specs, Global, Semantic & Component Tokens — Design Systems & Component Engineering
- CSS Custom Properties & Dynamic Theming Architecture — Design Systems & Component Engineering
- Tailwind CSS v4 Engine: CSS Variables & Theme Extensions — Design Systems & Component Engineering
- Dark Mode Strategies: System Preference, Class & High-Contrast — Design Systems & Component Engineering
- CSS Custom Properties: Scoping, Fallbacks And Theming — Frontend Architecture & Web Platform