Skip to content
Brand & Identity Design

A Practical Guide to Brand Color Tokens

A phase-by-phase guide to brand color tokens: audit colors, build base and semantic layers, check contrast, sync design variables with code, and add themes.

MediaScaleUp Editorial Team 24 min read 13 views
A Practical Guide to Brand Color Tokens

Brand color tokens are named design tokens for brand colors, such as color-brand-primary, that are used in design tools and in code so that colors stay consistent and can be updated in one place. Instead of a designer picking a hex value from a swatch and a developer copying it into a stylesheet, both refer to the same name. When the brand color changes, the value behind the name changes once, and every screen, component and product that uses the name picks up the new color.

That sounds like a small convenience, but it solves a real and expensive problem. Hard-coded color values drift across products. A button blue that started as one value ends up as four slightly different blues across the marketing site, the web app, the mobile app and the email templates, because each team copied it at a different time from a different source. Tokens let brand and theme changes roll out everywhere at once, and they make it possible to add a dark theme, a sub-brand or an accessibility fix without a search-and-replace across thousands of files.

This guide is for brand managers, designers, front-end developers and the people who coordinate between them. It is organized as a sequence of phases you follow in order, from auditing the colors you already use to documenting and governing the finished system. Each phase states its goal, the actions involved, what it should produce and how to check that it worked.

How brand color tokens are structured, and the procedure at a glance

Before starting, it helps to understand the two layers that almost every working token system uses. The first is the base palette: tokens that name raw colors, such as color-blue-600 or color-neutral-100. These describe what a color is, and they rarely change except during a brand refresh. The second layer is semantic tokens: tokens that name a purpose, such as color-text-primary, color-background-surface or color-action-primary. Semantic tokens point to base tokens. Components use semantic tokens, never base tokens directly.

This separation is what makes the system flexible. If the brand decides that primary actions should use a slightly deeper blue, you repoint color-action-primary from color-blue-600 to color-blue-700, and every primary button updates. If you add a dark theme, the semantic tokens map to different base values in the dark theme while components stay untouched. Some larger systems add a third layer of component tokens, such as button-primary-background, which point to semantic tokens; that layer is optional and worth adding only when components genuinely need to diverge from the semantic defaults.

In code, the usual implementation is CSS custom properties. In design tools, it is variables, such as Figma variables with modes for themes. The W3C Design Tokens Community Group is developing a shared format so that tokens can be exchanged between tools in a standard way, and it is worth keeping your source files close to that format so that future tooling can read them.

The full procedure runs in seven phases. Each is described in its own section below.

  1. Audit the colors in use Collect every color value from design files, code and templates, and group near-duplicates.
  2. Build the base palette Define a deliberate set of brand and neutral colors with scales and neutral names.
  3. Define semantic tokens by purpose Name the roles colors play (text, background, border, action, status) and map each to a base token.
  4. Check contrast for every semantic pairing Test each foreground and background combination that can actually occur, and adjust the mapping until all pass.
  5. Implement in code Publish tokens as CSS custom properties, generated from one source file, and replace hard-coded values.
  6. Mirror in design tools and sync Create matching variables in the design tool and set up a single source of truth that feeds both.
  7. Add themes, document and govern Map semantic tokens to theme values, document usage with examples, and agree on who can change what.

Phase 1: Audit the colors you actually use

Goal: find out how many colors exist across your products today, where they live and which ones are intended.

Most teams underestimate this. A brand guideline might specify six colors, while the codebase contains dozens of distinct hex values, some differing by a single digit. Those near-duplicates are rarely intentional; they come from eyedropping a screenshot, converting between color spaces, copying from an old version of the guideline or adjusting a shade by eye to fix a contrast problem locally.

Actions

  • Search the code for every color literal: hex values, rgb() and hsl() functions, named CSS colors, and color values inside JavaScript, email templates and native app resource files.
  • Export the color styles or swatches from your design files, including any local, unpublished colors used on individual screens.
  • Collect the colors specified in the brand guideline and any printed or PDF brand book, including their stated values in different color models.
  • Put everything in one spreadsheet with the value, where it appears, how many times it appears, and what it seems to be used for.
  • Group values that are visually indistinguishable or clearly meant to be the same color, and mark the intended value for each group.

Output

A color inventory: a list of every color in use, grouped into intended colors, with counts and locations. This inventory will tell you how much migration work lies ahead, and it is often the most persuasive document for getting the project approved, because it makes the drift visible. If you are doing a broader review of brand assets at the same time, a formal brand audit can fold this inventory into a wider assessment of consistency.

Checks

You are done when every color literal in the searched sources is either assigned to an intended color group or flagged as an exception with a reason. If you cannot explain why a color exists, that is a finding, not a failure.

  • All code repositories searched, including email templates and native apps
  • All design libraries and working files exported, including local colors
  • Brand guideline values recorded in every color model they are specified in
  • Near-duplicate values grouped, with one intended value chosen per group
  • Usage counts and locations recorded for each group
  • Unexplained colors flagged for decision rather than silently dropped
What to do and what to avoid with brand color tokens, side by side
Good practice against the usual mistakes, from the sources listed below.

Phase 2: Build the base palette

Goal: define a deliberate, complete set of raw colors from which every semantic role can be drawn.

A brand guideline typically gives you a primary color, one or two secondary colors and perhaps an accent. That is not enough for an interface. Interfaces need lighter and darker versions of the brand colors for hover and pressed states, backgrounds and borders; a full neutral scale for text, surfaces and dividers; and status colors for success, warning, error and information.

Actions

  • Start from the official brand values. Those anchor the scales and should appear exactly as specified.
  • Build a scale for each brand color, commonly numbered from 50 or 100 (lightest) to 900 (darkest), so that names like color-blue-600 describe position rather than purpose.
  • Build a neutral scale with enough steps to distinguish text, secondary text, borders, subtle backgrounds and surfaces. Many systems use ten or more steps.
  • Define status colors, with at least one shade that works as text on a light background and one that works as a background behind dark text.
  • Name base tokens by hue and step, not by use. color-red-600 is a base token; color-error is not.

Generating the intermediate steps of a scale by eye tends to produce uneven results, where some steps look much further apart than others. Perceptual color spaces such as OKLCH make it easier to build scales where lightness changes evenly, which in turn makes contrast more predictable in phase 4. Whatever method you use, check that each step is visibly distinct from its neighbors.

Shortcut: You do not need a full scale for every brand color on day one. Build complete scales for the primary brand color and the neutrals, which carry most of the interface, and add steps to secondary colors only when a semantic role needs them. Unused base tokens are clutter that someone will eventually misuse.

Output

A base palette file listing each base token and its value, with the official brand anchors marked. Keep it in a structured format such as JSON, because it will be the source for both code and design tools later.

Checks

Every intended color group from the audit maps to a base token, or has been deliberately retired. The official brand colors appear exactly. No two adjacent steps are indistinguishable, and no base token is named after a purpose.

Phase 3: Define semantic tokens by purpose

Goal: give every color decision in the interface a named role, so that components express intent and never refer to raw colors.

This is the phase that makes the system durable. The central rule is to name tokens by purpose, not appearance. A token called blue-button breaks the moment the brand decides buttons should be green, and it tells nobody whether it is safe to use for a link or a focus ring. A token called color-action-primary survives any rebrand, because its name describes what it does.

Actions

  • List the color roles the interface needs. A practical starting set covers text (primary, secondary, disabled, inverse, link), backgrounds (page, surface, raised surface, subtle), borders (default, strong, focus), actions (primary, primary hover, primary pressed, secondary) and status (success, warning, error, information, each with text and background variants).
  • Choose a naming structure and apply it consistently, for example color-[category]-[role]-[state], giving names such as color-text-primary, color-background-surface and color-action-primary-hover.
  • Map each semantic token to one base token for the default theme.
  • Resist creating a semantic token for every one-off. If a role is used once, ask whether an existing role fits before adding a new name.

An illustrative mapping

The table below is an illustrative example of how a small set of semantic tokens might map to base tokens in a light and a dark theme. The token names and pairings are examples to show the structure, not a recommended palette.

Semantic tokenPurposeLight theme maps toDark theme maps to
color-text-primaryBody text and headingscolor-neutral-900color-neutral-50
color-text-secondarySupporting text, captionscolor-neutral-600color-neutral-300
color-background-pagePage backgroundcolor-neutral-0color-neutral-950
color-background-surfaceCards and panelscolor-neutral-50color-neutral-900
color-action-primaryPrimary buttons and key linkscolor-blue-600color-blue-300
color-text-on-actionText on primary buttonscolor-neutral-0color-neutral-950
color-border-focusKeyboard focus indicatorcolor-blue-500color-blue-300
color-status-error-textError messagescolor-red-700color-red-300

Notice that the action color gets lighter in the dark theme, and the text placed on it flips from white to near-black. That is exactly the kind of change semantic tokens make painless: components ask for color-action-primary and color-text-on-action, and never need to know which theme is active.

Output

A semantic token file that references base tokens by name, plus a short description of each token's intended use.

Checks

No semantic token is named after a color or a visual appearance. Every semantic token points to a base token rather than a raw value. Every color used by a component can be expressed as one of the semantic tokens, or the gap is recorded.

  • Roles listed for text, backgrounds, borders, actions and status
  • One naming pattern chosen and applied to every token
  • No names that describe appearance, such as blue-button or light-gray-bg
  • Every semantic token references a base token, never a raw hex value
  • Each token has a one-line description of when to use it
  • One-off roles challenged before being added

Phase 4: Check contrast for every semantic pairing

Goal: make sure every foreground and background combination the system allows is readable, in every theme.

Tokens without contrast checks are one of the most common failures in token systems. The palette looks harmonious in a swatch grid, and then secondary text on a subtle surface turns out to be unreadable. Because semantic tokens define which colors can meet, they also make it possible to check contrast systematically instead of screen by screen.

Actions

  • List every realistic pairing: each text token against each background token it can appear on, text-on-action tokens against action tokens, focus and border tokens against the backgrounds they sit on, and status text against status backgrounds.
  • Calculate the contrast ratio for each pairing in each theme. The Web Content Accessibility Guidelines (WCAG) 2.x set a minimum of 4.5:1 for normal body text, 3:1 for large text, and 3:1 for user interface components and meaningful graphics such as focus indicators and input borders.
  • Where a pairing fails, change the mapping (point the semantic token to a different step) rather than creating an exception in a component.
  • Record states too. Hover, pressed and disabled states need checking, though WCAG does not require disabled controls to meet contrast minimums; many teams still set a floor so disabled text remains legible.

A simple script can do the arithmetic. It reads the token files, resolves each semantic token to its value per theme, computes contrast ratios for the listed pairings, and fails the build if any pairing drops below its threshold. That turns contrast from a review step into an automated guard that runs whenever someone changes a token.

Output

A pairing matrix listing each allowed combination, its ratio in each theme and its pass or fail status, and ideally an automated test that regenerates it.

Checks

Every pairing passes its threshold in every theme. Any pairing that is not allowed, such as secondary text on the primary action color, is explicitly documented as a combination to avoid.

Phase 5: Implement brand color tokens in code

Goal: make tokens the only way colors enter the codebase, generated from a single source file.

CSS custom properties are the natural implementation for the web. They cascade, they can be redefined inside a selector, and they can be changed at runtime, which is what makes theme switching straightforward. MDN Web Docs covers how custom properties are declared, inherited and read with the var() function, including fallback values and the difference between custom properties and preprocessor variables that disappear at compile time.

Actions

  • Keep the base and semantic token files as the source of truth, in a structured format such as JSON aligned as closely as practical with the W3C Design Tokens Community Group format.
  • Use a build tool to transform the source files into platform outputs: CSS custom properties for the web, and resource files for iOS and Android if you ship native apps. Style Dictionary is a widely used open-source option for this.
  • Emit base tokens and semantic tokens as custom properties on :root, with semantic tokens defined as references to base tokens, for example --color-action-primary: var(--color-blue-600);.
  • Replace hard-coded hex values in components with semantic token references, working component by component, starting with the most widely used.
  • Add a lint rule that flags new color literals in component code, so the migration does not reverse itself.

Shortcut: Do the migration in two passes. First, replace every hard-coded value with the matching semantic token without changing any visible color. That pass is safe to ship and easy to review. Only then adjust token values to the new palette, so that visual changes happen in one place and can be reviewed as a single diff.

Output

Generated token stylesheets, components that reference semantic tokens only, and a lint rule enforcing that.

Checks

A search for color literals in component code returns only documented exceptions. Changing a single base token value in the source file and rebuilding changes every place that color appears, and nothing else.

Phase 6: Mirror tokens in design tools and keep them in sync

Goal: give designers the same names and values as developers, from the same source, so that design files and code cannot drift apart.

Separate token sets in design and code are the quiet failure of many systems. The design library has a color called "Brand Blue" while the code has color-action-primary, and after a few months their values no longer match. Nobody notices until a launch review.

Actions

  • Create design tool variables that mirror the token structure: a collection for base colors and a collection for semantic colors that alias the base variables. The Figma Help Center explains how variables, collections, aliasing and modes work, including using modes for light and dark themes.
  • Use the same names in design and code, allowing only for the separator conventions each tool requires (for example, a slash-separated group path in the design tool and a hyphenated custom property in code).
  • Choose one direction of sync. Either the token source files feed the design tool through a plugin or API, or the design tool is the source and exports to the files. Two-way manual editing is how drift starts.
  • Scope semantic variables so that designers see the right tokens in the right places, such as only text tokens in text color pickers.
  • Hide or restrict base variables in the design library so that designers pick semantic tokens by default, just as developers do.

Output

A published design library with base and semantic variables, named to match code, fed from the same source.

Checks

Export the variable values from the design tool and compare them with the generated code output. They should match exactly. Pick three random screens in design files and confirm that every fill and text color uses a semantic variable.

  • Base and semantic collections created, with semantic variables aliasing base ones
  • Names match code apart from separator conventions
  • One source of truth and one sync direction agreed and documented
  • Variable scoping set so text, fill and border pickers show relevant tokens
  • Base variables hidden from everyday use in the published library
  • Design and code values compared automatically or on a fixed schedule

Phase 7: Add themes, document usage and set governance

Goal: use the semantic layer to support additional themes, and make the system understandable and controlled for everyone who uses it.

Adding themes

Semantic tokens can map to different values in light and dark themes. In code, that usually means redefining the semantic custom properties inside a theme selector or a prefers-color-scheme media query, while base tokens stay the same. In the design tool, it means adding a mode to the semantic collection. Components do not change at all.

A dark theme is not an inversion of the light theme. Pure black backgrounds with pure white text can feel harsh; many teams use a very dark neutral for backgrounds and slightly off-white text. Saturated brand colors that work on white often vibrate against dark backgrounds, so the action color frequently moves to a lighter, less saturated step. Elevation, which light themes usually show with shadows, is often shown in dark themes with slightly lighter surfaces. Every one of these decisions is a change to semantic mappings, and every one needs its contrast pairings rechecked.

The same mechanism supports sub-brands and co-branded products. A sub-brand can share the neutral scale and semantic structure while mapping action and accent tokens to its own base palette. How much a sub-brand should diverge is a question of brand architecture, and the practical steps are covered in our guide to launching a sub-brand.

Documenting usage with examples

A token list on its own does not tell anyone how to use it. Documentation should show each semantic token in context: a rendered example, the pairings it is allowed in, the contrast ratios, and do and don't examples. "Use color-text-secondary for captions and helper text on page and surface backgrounds; do not use it for body copy or on action colors" is far more useful than a name and a hex value.

Put documentation where people already look: next to components in the design system site, in the design library descriptions and in code comments generated from the token source. Link it from the brand guidelines, so that marketing and product teams read the same rules. Tokens sit inside broader brand infrastructure, which we cover in design systems as brand infrastructure.

Governance

Decide who can add or change tokens and how. A light process is usually enough: proposals go through a pull request or request form that states the purpose, the pairings affected and the contrast results; a named owner in design and one in engineering approve; changes are released with version numbers and a changelog. Base palette changes that alter official brand colors should also involve the brand owner. The wider question of who decides what in a brand system is explored in brand governance.

Output and checks

The output is theme mappings, published usage documentation and a written change process. You can check it by asking someone outside the core team to build a small screen in both themes using only the documentation. If they need to ask which token to use more than once or twice, the documentation needs more examples.

A worked example: migrating a product to brand color tokens

The following is an illustrative example, with invented but realistic numbers, to show how the phases fit together in practice.

Imagine a software company with a marketing site, a web application and a set of transactional email templates. The brand guideline specifies one primary blue, one accent orange and a dark gray for text. The team wants to add a dark theme to the web app and knows the brand blue is due for a slight adjustment.

In phase 1, the audit finds 47 distinct color values in the web app, 23 on the marketing site and 12 in email templates. After grouping near-duplicates, those collapse into 19 intended colors. Nine different blues turn out to be attempts at the brand primary. Four grays are used for body text in different places.

In phase 2, the team builds a ten-step blue scale anchored on the official primary, a twelve-step neutral scale, a short orange scale and four status colors with three steps each: 38 base tokens in all.

In phase 3, they define 31 semantic tokens covering text, backgrounds, borders, actions and status. In phase 4, the contrast script flags four failing pairings in the light theme, including secondary text on the subtle background, and seven in the first draft of the dark theme. Each is fixed by repointing a semantic token to a different step, with no component changes.

In phase 5, developers replace hard-coded values in 140 component files, first with no visible change, then by releasing the adjusted brand blue as a one-line change to the base token. In phase 6, the design library is rebuilt with variables fed from the same source. In phase 7, the dark theme ships as a second mode, and documentation pages go live for every semantic token.

The timeline below shows how that might be scheduled for a team with one designer and one or two developers contributing part of their time. Your schedule will depend mainly on the size of the codebase, the number of products and how much else the team is shipping.

  1. Week 1 Color audit across the web app, marketing site and email templates; inventory reviewed with the brand owner
  2. Week 2 Base palette built and approved; semantic roles drafted
  3. Week 3 Semantic mapping finalized for the light theme; contrast script written and failing pairings fixed
  4. Weeks 4 to 6 Code migration pass one: hard-coded values replaced with semantic tokens, no visible change; lint rule enabled
  5. Week 6 Design library variables created from the token source; sync direction agreed
  6. Week 7 Adjusted brand blue released through a single base token change
  7. Weeks 8 to 9 Dark theme mappings drafted, contrast-checked and tested with users
  8. Week 10 Dark theme released; usage documentation and change process published

The email templates are handled last in this example, because many email clients have limited or inconsistent support for CSS custom properties. The practical approach is to have the build tool output resolved hex values for email, generated from the same token source, so that the values stay in sync even though the delivery mechanism differs.

Common mistakes and how to recover from them

Most token projects that struggle do so for a small number of predictable reasons. Each has a recovery path that does not require starting again.

Hard-coded hex values in components

This is the default state of most codebases and the reason tokens exist. The recovery is the two-pass migration described in phase 5 plus a lint rule. Without the lint rule, new hard-coded values arrive faster than old ones are removed, especially from teams that were not involved in the project.

Tokens named after appearance

Names like blue-button, light-gray-bg or brand-orange-text lock the system to today's palette. To recover, introduce purpose-based semantic tokens that point to the same values, mark the old names as deprecated in documentation and tooling, and migrate usages over one or two release cycles before removing the old names.

Separate token sets in design and code

If the design library and the codebase each have their own list, they will drift. Pick one as the source, generate the other from it, and run a comparison on each release. The initial reconciliation can be tedious, but it only happens once.

Tokens without contrast checks

A beautiful palette can still produce unreadable pairings, especially after a theme is added. Build the pairing matrix from phase 4 and automate it. When a brand refresh changes base values, the automated check is what tells you which semantic mappings need to move.

Too many tokens

Systems sometimes grow a semantic token for every component and every state, until nobody can find the right one. If people routinely ask which token to use, consolidate. A smaller set of well-described semantic tokens is easier to use correctly than a larger set of precise but obscure ones.

Consistency problems rarely stop at color. The same patterns show up in typography, imagery and voice across channels, which is the subject of brand consistency across channels.

When to bring in outside help with color tokens

Many teams can run this playbook themselves, particularly if they have a single product and a front-end developer who is comfortable with build tooling. Bring in help when building a design system, adding themes, or updating brand colors across products. Those are the situations where the work touches several teams at once, where brand decisions and technical decisions have to be made together, and where a mistake in the base palette or the semantic structure is expensive to reverse later.

A brand refresh is a particularly good moment to introduce tokens, because the colors are going to change anyway. If you are weighing whether a refresh is due, our guide on when to refresh a brand sets out the signals worth watching. Smaller organizations can apply a lighter version of the same process, keeping the base palette and semantic set short; the approach in brand systems on small budgets applies directly.

When the scope includes the brand itself, not only its implementation, our brand and identity design team can take the work from palette decisions through to documented, synced tokens.

Whoever does the work, judge the result by three questions. Can a brand color change ship as a one-line edit to a base token? Can a new theme ship without changing any component? And does every allowed color pairing pass its contrast check automatically? If all three answers are yes, the token system is doing its job.

Where this comes from

The figures and practices above come from the sources listed.

Working on something like this?

We take on Brand & Identity Design work for teams who want it done once, properly. Tell us what you are building and we will tell you honestly whether we are the right studio for it. Start a project.

Where to go next

Spotted something wrong? Report an error on this page. We correct on the page and say what changed.

Frequently asked questions

They are named values for brand colors, such as color-brand-primary, used in both design tools and code. Everyone refers to the name instead of a hex value, so the color can be updated in one place and stay consistent across products.
Base tokens name raw colors by hue and step, such as color-blue-600. Semantic tokens name a purpose, such as color-text-primary, and point to a base token. Components use semantic tokens, which lets themes and rebrands change the mapping without touching component code.
The common approach is CSS custom properties declared on the root element and read with the var() function. Semantic properties reference base properties, and a theme redefines the semantic properties inside a selector or media query. A build tool can generate these stylesheets from a single token source file.
There is no fixed number. A small product might need a few dozen base tokens and around thirty semantic tokens, while a large multi-brand system needs more. Add a semantic token only when an existing role genuinely does not fit, because too many tokens makes the right one hard to find.
Semantic tokens map to different base values in each theme. In the dark theme, text tokens point to light neutrals, backgrounds to dark neutrals, and action colors often move to lighter steps. Every pairing needs its contrast rechecked in the new theme.
Choose one source of truth and one direction of sync, then generate the other side from it through a plugin, API or build step. Use matching names in both places and compare exported values on each release so drift is caught early.
WCAG 2.x sets 4.5:1 for normal text, 3:1 for large text, and 3:1 for interface components and meaningful graphics such as focus indicators. Check every allowed pairing of semantic tokens against these thresholds in every theme.
All services

The work behind this article, and what it costs.

MediaScaleUp Editorial Team

Articles here are researched, written and checked by the MediaScaleUp studio team before they are published, and dated when they are reviewed.

Keep reading

More in Brand & Identity Design