Design System Color Tokens: Primitive vs Semantic Colors
Structure color architecture for scalability, multi-theme support, and UI consistency.
Key Technical Takeaway
Design system color architecture separates primitive scales from semantic usage tokens. Mapping UI components to semantic tokens (e.g., --color-surface-bg) rather than hardcoded hex values enables multi-theme switching.
The 3-Tier Color Token Architecture
Enterprise design systems organize color tokens across three distinct abstraction tiers: Primitives, Semantics, and Components.
Tier 1: Primitive Tokens (Raw Values) -> e.g. --blue-500: #2563EB;
Tier 2: Semantic Tokens (Purpose/Role) -> e.g. --color-action-primary: var(--blue-500);
Tier 3: Component Tokens (UI Specific) -> e.g. --button-bg: var(--color-action-primary);Primitive Tokens: The Raw Palette
Primitive tokens hold raw color values organized by hue family and shade step (e.g. `slate-100`, `blue-500`, `red-600`). Primitives should never be imported directly into UI components; they serve exclusively as building blocks for semantic tokens.
Semantic Tokens: Intent & Meaning
Semantic tokens communicate purpose rather than appearance. They define structural roles like surface backgrounds, body text, primary actions, borders, and status feedback.
| Semantic Token Category | Example Token Name | Light Mode Mapping | Dark Mode Mapping |
|---|---|---|---|
| Background Surface | --surface-canvas | var(--slate-50) | var(--slate-950) |
| Container Surface | --surface-card | var(--white) | var(--slate-900) |
| Primary Text | --text-main | var(--slate-900) | var(--slate-100) |
| Muted Text | --text-muted | var(--slate-600) | var(--slate-400) |
| Border / Divider | --border-subtle | var(--slate-200) | var(--slate-800) |
| Primary Action | --action-primary | var(--blue-600) | var(--blue-500) |
| Status Error | --status-error | var(--red-600) | var(--red-500) |
Code Example: CSS Custom Properties & W3C JSON Tokens
Expressing color tokens in CSS custom properties and W3C design token JSON formats:
/* CSS Custom Properties Syntax */
:root {
/* Primitives */
--blue-500: oklch(0.58 0.23 250);
--slate-900: oklch(0.20 0.02 260);
/* Semantics */
--color-brand: var(--blue-500);
--color-text-body: var(--slate-900);
}
/* W3C Design Token Specification Format (JSON) */
{
"color": {
"action": {
"primary": {
"$type": "color",
"$value": "{color.blue.500}",
"$description": "Primary interactive button background"
}
}
}
}