Back to all articles
Written by Henry KlevorOct 8, 20265 min read

Making A better Design

The Architecture of Consistency: A Practical Guide to Design Tokens

When modern digital products scale, the friction between design and engineering inevitably grows. Designers refine spacing scales in Figma, while web developers tweak Tailwind configurations, iOS engineers update Swift asset catalogs, and Android developers adjust Jetpack Compose themes. Without a shared source of truth, visual drift occurs, redesigns become logistical nightmares, and accessibility fixes require tedious manual updates across multiple codebases.

Enter design tokens: the foundational atomic values that bridge design decisions and cross-platform implementation.

What Are Design Tokens?

At their core, design tokens are name-value pairs that represent repeatable design decisions. Rather than hardcoding a raw value—like a hexadecimal color code #2563EB, a padding value of 16px, or a border-radius of 8px—you capture that decision inside a named variable.

full-logo

{ "color": { "brand": { "primary": { "value": "#2563eb", "type": "color" } } } }

Design tokens abstract away platform-specific code. By maintaining decisions in a format-agnostic structure (most commonly JSON), they can be transformed automatically into:

CSS custom properties (var(--color-brand-primary))

SCSS/Sass variables ($color-brand-primary)

JavaScript/TypeScript objects (tokens.color.brand.primary)

Swift properties (Color.brandPrimary)

Android XML or Compose values (BrandPrimary)

The Three-Tier Architecture of Tokens

Not all tokens are created equal. A resilient design system organizes tokens into a structured hierarchy, typically divided into three layers:

┌──────────────────────────────────────────────┐ │ Component Tokens (e.g., button-bg-primary) │ └───────────────────────▲──────────────────────┘ │ references ┌───────────────────────┴──────────────────────┐ │ Semantic Tokens (e.g., color-action-hover) │ └───────────────────────▲──────────────────────┘ │ references ┌───────────────────────┴──────────────────────┐ │ Global / Base Tokens (e.g., blue-500) │ └──────────────────────────────────────────────┘

  1. Global Tokens (Base / Primitive)

Global tokens represent raw design decisions with no contextual meaning attached. They define your product's available visual palette.

color-blue-500: #2563EB

space-100: 4px

space-400: 16px

font-size-lg: 1.125rem

Rule of thumb: Global tokens should rarely be used directly in component code because they convey no intent.

  1. Semantic Tokens (Alias / Purpose)

Semantic tokens describe the role or context of a value rather than its literal appearance. They map directly back to base tokens.

color-background-surface: {color-neutral-0}

color-text-interactive: {color-blue-500}

space-inset-card: {space-400}

Semantic tokens are crucial for theming (such as light and dark modes). In light mode, color-background-surface might point to neutral-0 (white); in dark mode, the same token references neutral-900 (charcoal). The component consuming the token needs no conditional logic.

  1. Component Tokens

Component tokens scope values down to a specific UI element, decoupling the component's internal design from global shifts.

button-primary-background: {color-text-interactive}

button-padding-inline: {space-inset-card}

modal-border-radius: {radius-md}

While component tokens add an extra layer of abstraction, they allow teams to adjust individual components without unintended ripple effects throughout the rest of the application.

Token Taxonomy and Naming Conventions

The utility of a design token library hinges on how predictable and discoverable its names are. A chaotic naming scheme leads to confusion and developers falling back to hardcoded values.

A standard convention is the Category-Context-Property-Variant-State model:

[category]-[context]-[property]-[variant]-[state]

Examples:

color-surface-danger-subtle

color-button-primary-background-hover

typography-heading-xl-font-weight

border-card-interactive-focus

Keep names:

Predictable: Follow the same ordering structure across all categories.

Abstract from visual output: Prefer color-status-success over color-status-green.

Consistent in casing: Use kebab-case for multi-platform transformability.

The Automated Delivery Pipeline

Design tokens only succeed when they eliminate manual copy-pasting. The end-to-end workflow generally looks like this:

[Figma Variables] │ ▼ (Export / Sync via Plugin or API) [GitHub Repository: tokens.json] │ ▼ (Build step using Style Dictionary) ┌──────────────────────────────────────────────┐ │ • web/variables.css │ │ • ios/StyleTokens.swift │ │ • android/Tokens.kt │ │ • web/tokens.d.ts │ └──────────────────────────────────────────────┘ │ ▼ (Publishing) [npm package / CocoaPods / Maven Artifacts]

Step 1: Design in Tooling

Designers configure color styles, spacing variables, and typography in design software like Figma using native variables and plugins (e.g., Tokens Studio).

Step 2: Store in Source Control

Tokens are committed as structured JSON files in a dedicated repository or within a design system monorepo. This provides versioning, change history, and review workflows (Pull Requests) for design decisions.

Step 3: Transform with a Build Tool

Using an engine like Amazon's Style Dictionary, the source JSON is compiled into language-specific formats.

Here is an example Style Dictionary configuration (config.json):

{ "source": ["tokens/**/*.json"], "platforms": { "css": { "transformGroup": "css", "buildPath": "dist/css/", "files": [{ "destination": "_variables.css", "format": "css/variables" }] }, "ios": { "transformGroup": "ios-swift", "buildPath": "dist/ios/", "files": [{ "destination": "DesignTokens.swift", "format": "ios-swift/class.swift" }] } } }

Step 4: Distribution

Compiled assets are published as versioned packages (@company/design-tokens) so that client applications receive updates via standard package managers.

Benefits of Design Tokens

Challenge

Before Design Tokens

With Design Tokens

Theme Switching

Hardcoded media queries and complex CSS overrides

Swapping alias mappings at runtime via semantic tokens

Redesigns

Manual search-and-replace across multiple codebases

Changing base token values and regenerating outputs

Cross-Platform Sync

Mobile and web diverge visually over time

All targets share an automated single source of truth

Handoff Friction

"What hex code did you use here?"

"Use color-brand-accent."

Common Pitfalls to Avoid

Over-Tokenizing Too Early: Do not create component-level tokens for every single HTML element on day one. Start with base and semantic tokens; introduce component-level tokens only when complex overrides demand them.

Leaking Values into Names: Avoid names like font-size-14 or shadow-black-20. If the font size changes to 15px or the shadow color shifts to navy, the token name becomes misleading.

Bypassing the Pipeline: If engineers start modifying generated CSS or Swift files directly instead of updating the source JSON, the source of truth breaks down.

Summary

Design tokens are not merely a technical trick or a styling convenience—they represent a shared contract between design and development. By treating design decisions as structured, machine-readable data, teams unlock maintainable styling, effortless multi-theme support, and seamless cross-platform parity.