Color and Contrast Design Tokens

Color and Contrast Design Tokens

Build color tokens as palette primitives and semantic roles, and pair foreground with background and check the pairs against WCAG contrast in the build — in every theme, not just light.

Build the color token set in two layers — palette primitives that carry no opinion, and semantic color roles (surface, text, action, danger) that name intent and reference them — and treat foreground and background as a paired relationship, not two unrelated tokens. Bake WCAG 2.1 contrast into the pairing: SC 1.4.3 (Level AA) requires text and images of text to have a contrast ratio of at least 4.5:1, except that large-scale text and images of large-scale text need at least 3:1, and incidental text or images of text (part of an inactive user interface component, pure decoration, not visible to anyone, or part of a picture that contains significant other visual content) and text that is part of a logo or brand name have no contrast requirement. An on-surface text role should be defined so it is guaranteed to clear its ratio against its surface. Hold every theme to contrast independently, because a dark theme is not an inverted light palette — a design-system rule rather than a WCAG requirement, since WCAG's Understanding document also lists a sufficient technique (G174): providing a control with a sufficient contrast ratio that allows users to switch to a presentation that uses sufficient contrast, provided that the link or control itself meets the contrast requirement and the alternate presentation contains all the same information and functionality and conforms to all success criteria at the desired conformance level. Validate the pairs in the build so a failing one cannot ship. The honest limit: tokens record the intended pairs and a build step checks their contrast, but neither decides color meaning or brand. This guide covers the split, the contrast constraint, cross-theme pairing, and how to keep color honest.

Palette primitives versus color roles

Color, like the rest of the token system, works in two layers, and conflating them is where accessibility problems start. Palette primitives are the ramps — color.blue.500, color.neutral.900, a full set of steps per hue. A primitive is a raw value with no opinion about where it goes; color.blue.500 is a blue, not a button and not a link. Its only job is to be the single definition of that swatch. The Design Tokens Color Module 2025.10, a report of the W3C Design Tokens Community Group, calls this lowest layer "base tokens" in its non-normative naming section.

Semantic color roles sit above the ramps and name intent. color.surface.default, color.text.default, color.action.primary, color.text.danger — each names a job and points at whichever primitive currently fills it. The role is where meaning lives: it says "this is the default text color" without committing to a specific gray. Components consume roles, never primitives, which is what lets a theme or rebrand remap the roles underneath without touching a component.

The part that is specific to color is that foreground and background are not independent. A text role and the surface it sits on are a pair — color.text.default means nothing in isolation, only in relation to color.surface.default behind it. Treating them as two unrelated tokens is a direct route to contrast failures, because a value chosen for one without regard to the other can look fine on the palette and be unreadable in place. The relationship is the unit, not either token alone.

Contrast as a token-level decision

Once foreground and background are a pair, contrast becomes a property of the pair — and a constraint you can bake in rather than check after the fact. WCAG 2.1 Success Criterion 1.4.3 Contrast (Minimum) (Level AA) sets the minimums: the visual presentation of text and images of text needs a contrast ratio of at least 4.5:1 against the background it renders on, except that large-scale text and images of large-scale text need at least 3:1, and text or images of text that are part of an inactive user interface component, that are pure decoration, that are not visible to anyone, or that are part of a picture that contains significant other visual content (incidental text), as well as text that is part of a logo or brand name, have no contrast requirement. These ratios are stable, so they need no access-date caption; what matters is citing the criterion precisely and treating it as the rule the role pairs must satisfy.

The move is to define pairs so the on-surface role is guaranteed to clear its surface. Rather than picking a text color and hoping it reads, you pair a text role to a surface role and require the pair to meet 4.5:1. When that requirement is written into the token definitions and checked in the build, the guarantee travels with the tokens: any component using color.text.default on color.surface.default inherits a pairing the check has already proven to pass.

json
{
  "color": {
    "surface": { "default": { "$type": "color", "$value": "{color.neutral.50}" } },
    "text": {
      "on-surface": {
        "$type": "color",
        "$value": "{color.neutral.900}",
        "$description": "Paired with color.surface.default; meets WCAG 1.4.3 (>= 4.5:1)."
      }
    }
  }
}

Here color.text.on-surface is not a free-floating text color; it is defined as the partner of color.surface.default, and its value is chosen so the pair clears 4.5:1. The pairing is the token-level decision that makes accessibility a property of the system rather than a review someone might skip.

ContentWCAG 2.1 SC 1.4.3 minimumToken consequence
Normal text4.5:1 against its background (Level AA); incidental text or images of text (part of an inactive user interface component, pure decoration, not visible to anyone, or part of a picture with significant other visual content) and text in a logo or brand name have no requirementText role must clear 4.5:1 against its paired surface
Large text3:1 against its background (Level AA); the same incidental-text and logo or brand-name exceptions applyLarge-text role may use the relaxed 3:1 pair
Non-text UI (per 1.4.11)Separate criterion (Level AA): at least 3:1 against adjacent colors for the visual information required to identify user interface components and states, except inactive components or where the appearance of the component is determined by the user agent and not modified by the author, and for parts of graphics required to understand the content, except when a particular presentation of graphics is essential to the information being conveyedReferenced, not covered here

Color across themes

The pairing has to hold in every theme, and this is where the inversion shortcut fails. A dark theme is not an inverted light palette. Flipping every value can produce pairs that look plausible and fail in detail — a text-on-surface pair that cleared 4.5:1 in light does not automatically clear it once both ends are remapped to the dark ramp, because contrast is not symmetric under inversion. Hold each theme's role pairs to the criterion independently, which means the dark theme's color.text.on-surface and color.surface.default are their own pairing decision, verified on their own, not derived by negating the light one. That is a design-system rule rather than a WCAG requirement: the Understanding document for SC 1.4.3 also lists, as a sufficient technique (G174), providing a control with a sufficient contrast ratio that allows users to switch to a presentation that uses sufficient contrast. The technique's description says three things must be true for it to be used successfully: the link or control must itself meet the contrast requirement of the criterion, the alternate presentation must contain all the same information and functionality as the original, and it must conform to all success criteria at the desired conformance level. The mechanic of swapping value sets is covered in the article on theming; the rule here is that contrast is re-established per theme, not inherited.

State colors carry the same design obligation. Hover, disabled, and focus are role variants, and each should stay legible against whatever it renders on. Disabled needs a deliberate decision, because WCAG does not require contrast for it: text or images of text that are part of an inactive user interface component are incidental under SC 1.4.3 and have no contrast requirement, and SC 1.4.11 exempts inactive components (as well as components whose appearance is determined by the user agent and not modified by the author). A dimmed text role is still text a user is meant to read, or at least perceive, so a system can choose to give it a verified pair anyway. A focus indicator that loses contrast against its background defeats its purpose; the Understanding document for SC 1.4.11 says that, in combination with 2.4.7 Focus Visible, the visual focus indicator for a component must have sufficient contrast against the adjacent background when the component is focused, except where the appearance of the component is determined by the user agent and not modified by the author. Under this system's pairing rule, a state is not exempt even where WCAG exempts it; it is another pair to verify.

The illustrative shape is small: a text role and a surface role, paired, meeting a ratio — repeated per theme, with the dark theme's pair proven on the dark ramp rather than assumed from the light one. Multiply that discipline across the roles and states, enforce it with the build check described below, and contrast is guaranteed by construction for every declared pair in every theme the system ships.

Keeping color honest

The guarantee only holds if it is enforced, and the place to enforce it is the build or the review. A contrast check that runs over the role pairs turns a failing combination into a failed build instead of a shipped defect — the pair that dropped below 4.5:1 gets caught before it reaches a user, not after a bug report. Automating the check is what makes the token-level guarantee real rather than aspirational; without it, the pairing is a good intention that erodes the first time someone tweaks a value.

A second discipline keeps color names from lying. A color role should name its job, not its current appearance — color.action.primary, not color.action.blue. The article on token naming covers this rule in full, but the color-specific consequence is concrete: a value-leaking name becomes false the moment a rebrand changes the hue, and a token whose name contradicts its value is worse than no token. Name the role by intent so the name survives a repaint.

And the honest limit is where automation stops. Tokens can record the intended pairs, and a build step can check their contrast mechanically — that much is enforceable. What tokens cannot do is decide what the colors should mean or express. Which hue carries the brand, what "danger" should feel like, how warm or cool the surfaces read — those are human decisions about meaning and identity, and the token set records them faithfully without making them. A color token system with that check guarantees your declared pairs clear their contrast ratios and your roles are honest. It does not choose your palette; that judgment stays with the people designing the brand.

Project Inquiry