Complete the lesson quiz and earn 250 XP.
Pioneered by Jina Anne at Salesforce during the creation of the Lightning Design System, design tokens are the indivisible, platform-agnostic design decisions that power a design system.
Instead of hardcoding raw values like #0052CC or 16px across dozens of CSS stylesheets, iOS Swift structs, and Android XML files, teams store these decisions as named variables in a central, version-controlled repository:
{
"color": {
"brand": {
"primary": { "value": "#0052cc" }
}
}
}
When a token value is updated, an automated build pipeline compiles the tokens into CSS variables, iOS Swift constants, and Android XML resources, synchronizing every platform in seconds.
Mature design systems organize tokens into a three-tier hierarchy to maximize flexibility and protect against cascading breaking changes:
blue-500 = #2563eb, space-16 = 1rem). Never consumed directly in product UI.color-bg-interactive = {blue-500}, color-text-danger = {red-600}). This layer enables themes (Light/Dark mode) by swapping references.button-primary-bg = {color-bg-interactive}, modal-card-radius = {radius-lg}).Pro Tip: Product engineers should almost always consume Semantic Tokens (Tier 2). This guarantees that dark mode and rebranding work automatically.
Global tokens form the raw bedrock of your design system palette. They have no opinion on how, where, or why they are used. They simply enumerate the total allowable creative materials.
Examples of Global Tokens:
color-palette-blue-50, ...blue-500, ...blue-900.dimension-base = 8px.font-family-sans = 'Inter', -apple-system, sans-serif.duration-instant = 100ms, duration-standard = 250ms.Rule of Global Tokens: Never let feature squads write background-color: var(--color-blue-500) directly in a product layout! If the brand changes from blue to purple, every line of feature code will have to be rewritten.
Semantic tokens give meaning to raw primitives. They answer the question: 'What role does this token play in the user interface?'
Common Semantic Categories include:
color-bg-canvas (main background), color-bg-surface (cards, containers), color-bg-sunken (wells, inputs).color-text-primary (high contrast), color-text-secondary (body copy), color-text-muted (captions, disabled).color-feedback-success-bg, color-feedback-danger-text.color-interactive-default, color-interactive-hover, color-interactive-pressed.In Light Mode: color-bg-canvas = #F9FAFB and color-text-primary = #111827.
In Dark Mode: color-bg-canvas = #0F172A and color-text-primary = #F8FAFC.
Component tokens tie semantic decisions directly to individual components. They are the most granular tier in the system:
{
"button": {
"primary": {
"bg": { "value": "{color.interactive.default}" },
"bg-hover": { "value": "{color.interactive.hover}" },
"radius": { "value": "{radius.md}" },
"padding-x": { "value": "{space.16}" }
}
}
}
Why use Component Tokens?
Imagine executive leadership decides: 'We want all buttons to have 24px pill rounding, but cards and dialogs must keep sharp 8px corners.'
Without component tokens, changing {radius.md} would accidentally round cards, dialogs, and tables as well. Component tokens provide the isolation needed for targeted styling.
Inconsistent token names like primaryColor, color_bg_main, and theme-dark-btn create massive confusion. Leading systems (like Nathan Curtis's guidelines and Salesforce Lightning) use the Category-Type-Item (CTI) taxonomy:
{namespace}-{system}-{category}-{property}-{concept}-{variant}-{state}
Let's break down a real-world token: ux-sys-color-bg-surface-elevated-hover
ux (identifies the design system library)color (color, space, size, font, time)bg (background, border, text)surface (card, canvas, button)elevated (subtle, primary, elevated)hover (default, hover, active, disabled)Following a predictable formula makes tokens searchable, auto-completable in IDEs, and self-documenting.
How do tokens stored in JSON become usable code across different programming languages?
Teams use an open-source build tool like Style Dictionary (created by Amazon). Style Dictionary ingests a single directory of JSON/YAML tokens and transforms them into native artifacts:
:root { --color-bg-surface: #ffffff; }) or SCSS/TypeScript constants.Color.surface) and Objective-C headers.@color/surface) and Jetpack Compose objects.AppColors.surface).By automating this pipeline in CI/CD, a single token change pushed to Git builds and publishes new versioned packages for Web, iOS, and Android simultaneously.
Not all design decisions are single scalar values like a hex code or a pixel measurement. Complex design choices consist of multiple coordinated properties, known as Composite Tokens:
font-family, font-size, line-height, font-weight, and letter-spacing.x-offset, y-offset, blur-radius, spread-radius, and shadow-color (often combining ambient and directional shadows).border-width, border-style, and border-color.Composite tokens prevent desynchronization: designers cannot accidentally pick the right font size while forgetting the corresponding line height.
Design tokens reference other tokens in a chain of dependency:
{button-primary-bg} (Component Token)
↓ references
{color-interactive-primary} (Semantic Token)
↓ references
{blue-600} (Global Primitive Token)
↓ evaluates to
#1d4ed8 (Raw Hex Value)
Rules for Healthy Token Dependency Chains:
What happens when the design system team realizes a token name is confusing and needs to be renamed (e.g., renaming color-brand to color-interactive-primary)?
If the team simply deletes the old token in the next release, every consuming frontend app using that token will break.
The Safe Token Migration Pattern:
color-interactive-primary to the system.color-brand, but point its value to {color-interactive-primary}. In the documentation and compiler, mark color-brand as @deprecated.Consider an enterprise holding company that owns three distinct online fashion brands: 'Luxe' (minimalist, monochrome, high contrast), 'Sport' (vibrant neon greens, energetic), and 'Casual' (warm earthy pastels).
Rather than building three separate codebases or three separate component libraries, the engineering team uses token theming:
<Button>, <Modal>, <Card>).<html class="theme-luxe"> vs <html class="theme-sport">), instantly transforming typography, colors, borders, and shadows without changing a single line of component code.