
Theming With Design Tokens
A theme is a value remap at the semantic tier, not a pile of overrides. How tokens make color scheme (light or dark), brand, and density composable — and what stays real design work.
TL;DR: A theme is not a pile of overrides — it is an alternate set of values at the semantic tier, layered over primitives and components that never change. Color scheme (light or dark), brand, and density are composable theme dimensions, each supplying a complete value set for the same semantic names. The mechanism makes theming a value swap; deciding the right values per theme — especially contrast — is still real design work that tokens do not do for you.
A theme is a set of semantic values
The instinct many teams start with is to build a base theme and then override it: dark mode as a list of exceptions to light mode, a brand as a patch on the default. That approach tends to rot, because the override list grows each time something is missed and it becomes hard to say what the full set of differences actually is. Tokens offer a cleaner model.
A theme remaps the semantic tier and leaves everything else in place. Primitives — the raw palette of specific colors and dimensions — stay put. Components stay put. What changes between themes is the set of values behind the semantic names. A semantic token like color.surface.default resolves to a light value under the light theme and a dark value under the dark theme, and that difference is the theme. The name is constant; the value it points at is what the theme supplies.
The payoff is that components never know which theme is active. A component asks for a role — give me the default surface, give me the primary text color — and gets whatever the current theme resolves that role to. It does not branch on the theme, does not check whether dark mode is on, and does not carry theme-specific code. Because components consume semantic roles rather than concrete values, a new theme is a new value set, not a change to a single component. That indifference is the whole point: theming stays entirely in the token layer.
Building a theme set
Building a theme starts by defining the semantic names once — the roles the whole system speaks in, like default surface, raised surface, primary text, muted text, accent. Those names are the contract. Each theme then supplies a complete value set for that same set of names. Light supplies its values, dark supplies its own, and any additional theme does the same, all speaking the identical vocabulary of semantic names.
The example below shows one semantic name resolving to two different values across two themes. Read it as illustrative shape, not as a specific tool's file.
Semantic name (shared across themes): color.surface.default
Light theme: color.surface.default -> color.neutral.50 (#F9FAFB)
Dark theme: color.surface.default -> color.neutral.900 (#111827)
Same name, two value sets. The component only ever asks for color.surface.default.Themes compose as dimensions rather than as one flat list. Color scheme (light or dark) is one dimension; brand is another; density — compact versus comfortable spacing — is a third. A concrete theme is a point in that space: the dark, brand-B, compact combination is a value set assembled from those choices. Treating them as composable dimensions keeps the number of hand-authored value sets manageable, because you are combining a few well-defined axes rather than enumerating every possible finished theme by hand. Brand is worth calling out as just one such dimension here; scaling a system across many brands has depth of its own, covered in the article on multi-brand tokens.
Coverage and contrast are the hard parts
The mechanism is simple; making a theme correct is not. The first hard requirement is coverage. Every semantic token must resolve to a valid value in every theme. If the dark theme defines nineteen of twenty semantic names and forgets the twentieth, then any component that consumes the twentieth gets the wrong value the moment dark mode is active. With CSS custom properties, it may quietly keep the light value inherited from an enclosing scope; where nothing defines the token and the var() reference has no fallback, the declaration is invalid at computed-value time and the property falls back to its inherited or initial value. Either way, it will be the one screen nobody tested. A theme is only done when its value set is complete against the full list of semantic names, and a build that checks coverage is worth having.
The second hard requirement is contrast, and it is where the value-swap framing can mislead. A dark theme is not the light palette inverted. Flipping light values to dark ones can produce text that fails against its background, accents that disappear, and states that become indistinguishable. Each theme's color choices should be checked on their own for contrast between foreground and background roles, against the contrast thresholds you target, rather than assumed to carry over from another theme. This article flags that check rather than teaching it — the depth of how contrast is calculated and guaranteed is covered in the article on color and contrast — but the check itself belongs to every theme.
Density and spacing themes are a reminder that theming is not only about color. A compact theme remaps scale semantics — the values behind spacing and sizing roles — not the palette. The same role name, spacing.inset.md, resolves to a tighter value in a compact theme and a roomier one in a comfortable theme. The pattern is identical to color: alternate value sets over shared semantic names, applied to a different family of decisions. The values in the table below are illustrative, not recommendations.
| Semantic role | Light theme value | Dark theme value | Compact theme value |
|---|---|---|---|
| color.surface.default | color.neutral.50 | color.neutral.900 | (inherits color theme) |
| color.text.default | color.neutral.900 | color.neutral.50 | (inherits color theme) |
| spacing.inset.md | 16px | 16px | 12px |
Where the theme is applied
There are two broad places a theme gets applied, and the choice belongs to the runtime rather than to this article. Build-time theming produces one output per theme — a separate stylesheet for light and for dark — and the application loads the right one. Runtime theming swaps the values live on a scope, using CSS custom properties so a single set of components re-resolves to new values without a rebuild. The mechanics of that runtime swap — how the cascade carries the values, how scope works — are covered in the article on CSS custom properties; here it is enough to know both approaches exist and that they trade rebuild-time simplicity against live-swap flexibility.
One runtime concern is worth naming because it bites teams who ignore it: a flash of the wrong theme on load. If the page paints with the default theme before the user's actual preference is applied, they see a flicker from light to dark. Whether the runtime picks light or dark can follow the user's system setting via prefers-color-scheme, and applying the resolved theme before first paint is what avoids the flash. This is a runtime problem, flagged here and solved in the runtime, not in the token definitions.
The honest limit closes the loop. Tokens make a theme a value swap — that is the genuine and valuable simplification. What they do not do is decide the values. Choosing the exact colors for a dark theme that both match the brand and pass contrast, tuning a compact density that stays usable, defining a brand dimension that feels coherent — that is design work, and it is real. The token layer gives you a clean place to put those decisions and, for components that consume semantic tokens rather than hard-coded values, a reliable way to have them honor those choices, but it does not make the decisions. Anyone expecting tokens to generate a correct dark theme from a light one will be disappointed; the value swap is automatic, the values are not.