Dark Mode Token Architecture Without Duplicate Palettes
One semantic token layer supports multiple themes without duplicating design decisions.
Dark mode can work without a second palette. It requires a semantic layer that changes which values serve which roles. Separating primitives, semantic decisions, and component overrides lets one token system support light and dark modes, multiple brands, and machine-readable brand context without duplicating the decisions that hold an interface together.
Why dark mode breaks when it's treated as a palette problem
A dark-mode pull request that touches every component exposes an architectural problem. So does maintaining two Figma files for the same interface. Both arrangements spread theme decisions across places that must then be kept in agreement. Defining separate colors seems reasonable because dark mode looks different, but it confuses appearance with the rules that produce it. Each extra palette is another place to maintain where those rules can drift.
Direct inversion makes the same mistake through a different shortcut. Globally swapping light values for dark equivalents loses spatial distinctions when shadows cannot read against near-black surfaces. Cards and modals then appear flat even though their colors have changed. The failure is not a shortage of dark colors, but the absence of explicit decisions about where each color belongs.
What a token actually is, and why the naming convention is the architectural hinge
A design token is a mapping from a decision to a value. A palette lists the colors on hand, while a token system says what each one is for. The decision “the surface a card sits on” can map to #f7f7f5 in light mode and #1a2238 in dark mode. Theme switching therefore changes the mapping rather than requiring a search through components for hardcoded colors.
A name that describes a pale gray is misleading if it holds a dark surface color in another theme. Every consumer must then remember an exception that the token system should have removed. A mode-agnostic name instead describes a surface, primary text, or an interactive role, so it stays true across themes.
The W3C Design Tokens Community Group published DTCG 2025.10 as the first stable version of its JSON format. That provides a stable interchange format for carrying named decisions between tools, although individual implementations still need attention. A standard format cannot compensate for names that encode the wrong concept. Once a token is understood as a decision rather than a value, separating raw material, contextual meaning, and local use follows naturally.
The three tiers of primitives, semantics, and component tokens
Primitives hold raw values under neutral names. For example, blue-500 holds #3b82f6, while zinc-50 holds #fafafa. These tokens describe the available raw values. With that boundary in place, a primitive stays the same when the active theme changes. The palette remains a shared source rather than becoming a second set of role-specific values.
Semantic tokens assign that material to interface roles. For example, --color-bg-surface resolves to var(--zinc-50) in light mode and var(--zinc-900) in dark mode. Names can follow category, role, and emphasis, as in color/surface/default or color/text/primary. This is the tier components consume and the tier whose mappings change between themes. It separates the meaning of a surface from the color chosen to render it.
In CSS, the light mappings live on :root, while a [data-theme="dark"] block redefines the same semantic tokens. The alternative is to apply the dark mappings through prefers-color-scheme. Components update through the variables they reference, without dark-mode rules of their own. A high-contrast theme or tenant override adds another set of semantic mappings. It does not require a different component structure.
Component tokens provide local overrides where the shared semantics need a narrower expression. For example, button-bg can resolve to var(--color-interactive), preserving the chain from component token to semantic token to primitive. Use these sparingly because each new component token may point to a role missing from the semantic vocabulary. CSS variable inheritance contains an override declared on .card within that component’s subtree. By contrast, choosing blue-500 directly for a card background bypasses the decision layer and makes that component a separate dark-mode task.
Dark mode specifics that can't be handled by remapping alone
The semantic layer supplies the mechanism, but the dark mappings still require perceptual design. On a pure black #000000 background, high-luminance white text can seem to bleed and glow through optical halation, which can blur the text and tire the eyes. Dark grays provide the base surface used by professional dark interfaces instead. That base then needs distinct relationships with elevated surfaces. Replacing white with black does not establish those relationships.
Cards and sidebars sit lighter than the base canvas, while dropdowns and modals occupy another step above them. Material Design 3 uses a primary-color surface-tint overlay whose opacity relates to elevation in both light and dark themes, and it has also introduced dedicated surface-container roles as an alternative. Both approaches make lightness carry spatial meaning. Semantic names such as --color-surface-base, --color-surface-raised, and --color-surface-overlay keep that meaning clear in the token system.
Static text alpha values can produce unpredictable contrast when the surface beneath them changes, so dark mode needs structured emphasis tiers, including high-emphasis body text at 87% opacity and progressively lower medium-emphasis and disabled states. A vibrant blue that passes WCAG 4.5:1 on white may fail against a near-black surface, requiring a desaturated, luminance-boosted target for the same interactive role. Danger, warning, and success are different because their meaning must remain fixed, so their semantic tokens should be excluded from theme-variant generation.
Tooling that operationalizes the architecture through Style Dictionary, Figma Variables, and Tailwind v4
Style Dictionary transforms token JSON into targets including CSS variables, a Tailwind theme, Swift constants, and Kotlin resources. Checks at build time can make sure names follow the naming patterns, color formats are valid, aliases resolve, and theme mappings are complete. Every semantic token needs light and dark variants or an explicit annotation that it has no theme variant. Style Dictionary has first-class DTCG support from version 4, but its documentation notes that full support for the latest 2025.10 format remains work in progress in v5.
Figma Variables provide the design-side home for primitives and semantics. Components bind to semantic aliases, while Light, Dark, and High Contrast modes belong on the semantic collection. One base component library can then preview theme changes without maintaining separate component designs. Export through a plugin or the Figma API carries those decisions into DTCG JSON for the build pipeline. The important continuity is the alias relationship.
Tailwind v4 carries that relationship into CSS through @theme. Variables declared there become CSS custom properties and generate utility classes, so semantic names can be used in utilities such as bg-surface. Those utilities refer to runtime variables, so a theme’s color values are not fixed in the component markup. Variables that should stay as plain CSS without generating utilities go on :root. The theme toggle then changes the values beneath the classes.
The first render still needs care to keep the wrong theme from flashing on screen. Set the initial theme class synchronously with an inline script in <head>, persist the user’s choice in localStorage, and reconcile it with prefers-color-scheme on first paint. Render the chosen class server-side when that is possible. With the export, validation, and build steps connected, the three tiers extend from design to implementation, and a token change in Figma propagates to CSS without manual coordination.
How the same token architecture extends to multi-brand and multi-tenant systems
A brand is another context in which the same interface decisions receive different values. A shared Card component can use --color-surface-raised, with the mapping coming from each brand’s token file. A scoped selector such as [data-brand="tenant-a"] performs the same structural job as the dark-theme selector. The component only needs the semantic contract to remain intact.
This separation can carry typography scales, spacing systems, and border treatments as well as color. Styling for each brand stays in the token layer, while tenants share the code that gives components their structure. UK fintech white-label implementations using this structure have brought a new tenant’s dashboard to a correct rendered state by changing a small, bounded set of semantic tokens. The architectural benefit is that tenant differences have a defined place to live. They do not become scattered exceptions in otherwise shared components.
That boundary fails if a second brand simply forks a monolithic token file. A theme object that redeclares the primitive palette likewise creates a parallel design system. Product UI must consume semantic tokens, and brand variation must preserve the fixed meaning of status roles. The scalable unit is one component layer and one semantic contract that each brand implements independently through its own mappings.
Why AI agents break on flat palettes and behave on semantic tokens
A flat palette tells an AI agent which values exist but leaves it to infer where they belong. Semantic tokens give the agent a constrained vocabulary for those choices. An instruction to use --color-accent for the primary button is more precise than a request to use the brand’s blue. The first identifies a decision already made, while the second asks the agent to make it again.
For generated output, forbidding raw color, radius, and duration values in favor of token references removes a common source of visual inconsistency. The constraint also lets the same machine-readable decisions inform a LinkedIn carousel, an email template, a paid ad creative, and a UI component without manually re-entering brand values. A traditional brand-book PDF is organized for human reading. A token file already expresses decisions in a form an agent can consume.
Rainbrand’s Brand Skill applies this principle by ingesting existing brand assets and exposing structured, versioned, retrievable context. Connected agents and products can retrieve it through API or MCP, including tools such as Claude, Cursor, and ChatGPT. Publishing an edit makes a new version available for connected systems to use on their next task, but existing outputs do not change automatically. That distinction matters because retrieving current brand context is not the same operation as a live interface resolving updated CSS variables.
Maintaining token systems over time without drift
Even a well-designed token architecture can decay into duplicate palettes if its boundaries are not enforced. A change to the primary color or spacing, or the addition of a new tenant, should go through the semantic contract without overrides scattered across consumers. Build checks can block primitive hex values in components, reject missing dark-mode variants, and validate WCAG contrast automatically. These checks remove the need to remember the rules on every change. They make the architecture a condition of delivery.
Automation still cannot fully judge whether a name means what it claims. A token called --surface-base may resolve correctly while having been repurposed to hold a border color. A designated token owner, a pull-request token checklist, and periodic drift audits address that semantic failure. Versioning then shows every consumer what has changed through tagged releases, changelogs, and breaking-change notices. Tools and agents need that notice when a name changes meaning or is deprecated.
To migrate incrementally, stop adding screens without semantics, map the most-used fills to semantic tokens, update library components first, and then sweep product files section by section. After migration, token changes deserve the review rigor of a schema migration because they alter a shared contract. A duplicate palette is therefore not merely a CSS problem, but a governance failure. The three-tier architecture resolves it structurally only when the token layer remains versioned, owned, and enforced.