Sub topic 7
Share decisions through design tokens
This chapter covers design tokens: what they are, how to structure them in layers, how to build platform outputs from them, and where they fail. It assumes you know the brand elements from the visual identity chapter (logo, color, typography, spacing). You should also be able to read basic JSON and CSS. A little command-line experience helps for the build example.
Why tokens exist
A visual identity system says "our primary blue is #1A4D8F." That decision then has to reach the website, the iOS app, the Android app, email templates, and slide decks. If each team copies the hex value by hand, the copies drift. One team rounds a color, another picks a similar font, and a third forgets the update after a rebrand.
A design token is a named value that stores a single visual decision, such as a color, a font family, or a spacing unit. The name carries the meaning ("brand primary"), and the value can change without anyone renaming anything. Tokens are stored once in a platform-neutral format. Each team generates its own format from that source: CSS variables, Swift constants, Android resources, or email-safe inline values.
Tokens move the source of truth out of a PDF and into a file that code can read. Brand guidelines describe the rules for people. Tokens carry the same rules to machines.
The source file
The following file stores the brand's colors, fonts, and spacing once.
{
"color": {
"brand": {
"primary": { "value": "#1A4D8F" },
"accent": { "value": "#F2A900" }
},
"text": {
"default": { "value": "#1B1B1B" },
"inverse": { "value": "#FFFFFF" }
}
},
"font": {
"family": {
"heading": { "value": "Georgia, serif" },
"body": { "value": "Arial, sans-serif" }
}
},
"space": {
"base": { "value": "8px" }
}
}Each leaf is an object with a value. The nesting forms the token's path, for example color.brand.primary. Build tools join the path into a name such as --color-brand-primary. The path is the token's identity, so choose it carefully.
From source to platforms
The flow is one source, one transformation step, and many outputs.
The web output of the source file above looks like this:
:root {
--color-brand-primary: #1A4D8F;
--color-brand-accent: #F2A900;
--color-text-default: #1B1B1B;
--color-text-inverse: #FFFFFF;
--font-heading: Georgia, serif;
--font-body: Arial, sans-serif;
--space-base: 8px;
}
.button-primary {
background-color: var(--color-brand-primary);
color: var(--color-text-inverse);
font-family: var(--font-body);
padding: var(--space-base) calc(var(--space-base) * 2);
}The .button-primary rule never contains a hex code. It references names. When the brand blue changes, you edit one value in the source, rebuild, and every component that references --color-brand-primary updates.
Automating the build
You can write the transformation yourself, but most teams use a tool such as Style Dictionary. This configuration generates the CSS file above. Save it as config.mjs next to a tokens/ folder that holds the JSON source.
export default {
source: ['tokens/**/*.json'],
platforms: {
css: {
transformGroup: 'css',
buildPath: 'build/css/',
files: [
{
destination: 'tokens.css',
format: 'css/variables'
}
]
}
}
};Run it with npx style-dictionary build --config config.mjs. To add iOS or Android, add another entry under platforms with that platform's transform group and format. The source file does not change.
Layer your tokens
A flat list of colors works for a small brand. It breaks down as soon as you need dark mode, a sub-brand, or a seasonal campaign. The usual fix is three layers.
| Layer | Also called | Example name | Example value | Purpose |
|---|---|---|---|---|
| Primitive | Global, reference | `color.blue.700` | `#1A4D8F` | The raw palette. Says what exists. |
| Semantic | Alias | `color.action.primary` | `{color.blue.700}` | Says what a value is for. |
| Component | Scoped | `button.background` | `{color.action.primary}` | Says where it is used. |
A semantic token points at a primitive instead of repeating its value. This is an alias. In the JSON format above, an alias looks like this:
{
"color": {
"blue": {
"700": { "value": "#1A4D8F" }
},
"action": {
"primary": { "value": "{color.blue.700.value}" }
}
}
}The reference syntax differs between tools and versions. Some accept {color.blue.700} and others require the trailing .value. Use whatever your build tool documents.
Layers pay off in three situations:
- Theming. A dark theme redefines
color.action.primaryto point at a lighter primitive. No component changes. - Rebrands. You change a few primitives, and every semantic and component token follows.
- Sub-brands. Each sub-brand supplies its own semantic mapping over a shared primitive set.
The rule of thumb is that components should reference semantic tokens, and almost never primitives. A component that reads color.blue.700 directly cannot be re-themed.
Naming rules
Names are the part of a token system that people actually use, so most failures start here.
- Name by purpose, not by appearance.
color.text.defaultsurvives a rebrand.color.dark-graybecomes a lie the day the text turns navy. - Use a consistent order. A common pattern is category, then property, then variant, then state:
color.text.link.hover. - Keep scales predictable. Use numeric steps (
100,200,300) or t-shirt sizes (sm,md,lg) for ranges, and do not mix them in the same category. - Avoid brand-product names in primitives when you expect more than one brand to share the system.
Tokens and accessibility
Accessibility is a brand requirement, and tokens are a good place to enforce it. Pair tokens deliberately so that text and background combinations are known to be readable. The example source defines color.text.default (#1B1B1B) and color.text.inverse (#FFFFFF). The inverse text on the brand primary (#1A4D8F) is the combination the button uses. You should check that pair against the WCAG contrast minimum of 4.5:1 for normal text, and record the result.
Some teams add an automated check to the build. It reads each approved text and background pair and fails the build if a ratio drops below the threshold. A rebrand that quietly makes buttons unreadable then fails in the build instead of reaching customers.
Spacing tokens help too. A base unit of 8px, with other sizes as multiples, keeps tap targets and gaps consistent. It also supports minimum target sizes on mobile.
Where tokens stop
Tokens carry values, not judgment. The following are common gotchas.
- Tokens do not replace guidelines. A token says the heading font is Georgia. It does not say when to use a heading, how long it should be, or what the voice should sound like. Link each token group to its guideline page.
- Not every platform can use every value. Email clients ignore CSS custom properties, so the email build must resolve
var(--color-brand-primary)to a literal hex value. Many email clients also lack web fonts, so the email output should include a fallback stack. Resolve aliases at build time for such targets. - Over-tokenizing creates noise. If every one-off margin becomes a token, nobody can find the right one. Create a token when a value is reused across more than one component or must change in sync with others.
- Under-tokenizing recreates drift. If developers hard-code
#1A4D8Fbecause the token "wasn't quite right," you have two sources of truth again. Treat that as a signal to fix or add a token. - Platform differences are real. A pixel value for the web may become density-independent units on Android. The transform step handles unit conversion, but a human should review the first output on each platform.
- Breaking changes spread fast. Renaming
color.brand.primarybreaks every consumer at once. Publish tokens as a versioned package, use semantic versioning, and deprecate old names for a release or two before removing them.
Ownership and workflow
Tokens only work if someone owns them. The governance chapter covers approvals in detail. For tokens, the minimum setup is as follows:
- Keep the source in version control, with a named owner or small group.
- Require a review for any change to a primitive or semantic token, since these affect every channel.
- Publish releases with a changelog that says which names changed.
- Let each channel team pin a version and upgrade on its own schedule, within an agreed time window.
This routine feeds the brand audit later in the tutorial. When you audit a touchpoint, one question is which token version it uses. A touchpoint on a version two years old is a drift risk.
Summary of the working model
Tokens turn visual identity decisions into data. A source file holds primitives, semantic aliases, and optionally component tokens. A build step generates outputs for each platform. Components reference names instead of values. Changes flow from one reviewed place to every channel.
Exercise
Your team's button.background token currently points directly at the primitive color.blue.700. Marketing asks for a dark theme in which buttons use a lighter blue. Explain what you would change in the token structure, and why this is better than editing the button component.
Show answer
Add a semantic token such as color.action.primary that aliases color.blue.700, and point button.background at that semantic token. For the dark theme, redefine color.action.primary to alias a lighter primitive, for example color.blue.300. The button component keeps referencing the same token name and picks up the right color for each theme. Editing the component would hard-code theme logic into it and repeat the work in every other component that uses the primary action color.
Exercise
A developer on the email team notices that var(--color-brand-primary) shows as no color in several email clients. What is the cause, and how should the token build handle email?
Show answer
Many email clients do not support CSS custom properties, so the variable never resolves. The build should generate a separate email output in which every alias and variable reference is resolved to a literal value, such as the hex code #1A4D8F, and written inline or in a format the email templates can use. Fonts need a fallback stack too, since web fonts are often unavailable. The source tokens stay unchanged.
Exercise
Name two reasons to avoid a token called color.dark-gray for body text, and give a better name.
Show answer
First, the name describes appearance, so it becomes misleading if a rebrand changes body text to a navy or near-black. Second, it does not tell a designer or developer where to use it, so people may reuse it for borders or icons and break the link between meaning and value. A better name is color.text.default, which describes the purpose and survives value changes.