Design practice

Build a Token Pipeline

Set up a W3C-compliant token system with Style Dictionary and CSS custom properties

01 / Prepare

What you’ll
work on.

Build a working design token pipeline from JSON source files to CSS custom properties output, following the W3C Design Token Format and using Style Dictionary v4. You will define reference, semantic, and component tokens for a small design system.

Before you begin

  • Node.js installed
  • Basic command-line familiarity
  • Understanding of CSS custom properties
  • Understanding of reference, semantic, and component token tiers

02 / Practice

The work,
step by step.

Work through these 4 parts at your own pace. Keep your notes and work together so you can review them when you finish.

  1. Token Source Files

    90 min

    1. Create the project structure with reference/, semantic/, and component/ directories under a tokens/ folder

      tokens/
      ├── reference/
      │   ├── color.json
      │   ├── typography.json
      │   └── spacing.json
      ├── semantic/
      │   ├── color.json
      │   ├── typography.json
      │   └── spacing.json
      └── component/
          └── button.json
    2. Define reference tokens — Raw values: a color palette (8–10 colors with tint scales), a type scale (6–8 sizes), a spacing scale (4px base, 8 steps)

    3. Define semantic tokens — Intent-based aliases: color.surface.primary, color.text.primary, color.interactive.primary, typography.heading.lg, spacing.gap.md

    4. Define component tokens — Button-scoped: button.primary.background, button.primary.text, button.padding.horizontal

  2. Style Dictionary Configuration

    60 min

    1. Install Style Dictionary

      npm install style-dictionary@4
    2. Write the config — Register source files, define CSS custom properties output

    3. Build — Run the pipeline, verify output CSS file

    4. Inspect the output — Confirm tokens resolve through the chain (component → semantic → reference)

  3. Multi-Theme Support

    60 min

    1. Create a dark theme override — New semantic token file that remaps surface and text colors

    2. Configure two build targets — :root (light) and [data-theme="dark"] (dark)

    3. Build both themes — Verify the same component tokens resolve to different values per theme

  4. Documentation

    30 min

    1. Write a brief README — What the tokens are, how to build, how to add a new token

    2. Document naming conventions — tier-category-variant-state pattern

03 / Review

Look at what
you’ve made.

Gather your deliverables, then use the criteria to find what worked and what you would change. They also give a peer something specific to respond to.

What to bring together

  • Token source files (JSON, W3C format)
  • Style Dictionary config
  • Generated CSS output (light + dark themes)
  • README with naming conventions

How to assess your work

Token structure
Clean three-tier architecture with proper aliasing
Naming
Consistent, predictable naming that communicates intent
Theming
Dark theme works through token remapping, not hardcoded overrides
Build pipeline
Style Dictionary config is clean and extensible

Choose your
next exercise.

Browse all exercises