Skip to content
Back to blog
Engineering

Inside our design token pipeline

One source of truth for color, type and spacing — compiled to CSS, Swift and Kotlin on every merge. How we keep three platforms looking like one product.

Priya Raman

Head of Design

Published
Reading time
1 min
An overhead view of a desk covered in technical drawings while someone sketches on one of them
Photograph via Unsplash

Leaf ships on the web, iOS and Android. For years, each platform had its own idea of what 'the gray' was. The differences were small enough that nobody filed a bug and large enough that, side by side, you could tell something was off. Tokens fixed that.

A single source

Everything starts in one JSON file per category: color, typography, spacing, radius, motion. Values are semantic first — text.primary, not gray-900 — with a primitive layer beneath them.

tokens/color.json
{
  "color": {
    "text": {
      "primary": { "value": "{color.ink.900}" },
      "muted":   { "value": "{color.ink.500}" }
    },
    "ink": {
      "900": { "value": "#1B1A17" },
      "500": { "value": "#6A665C" }
    }
  }
}

The build

On every merge to main, a small script resolves references, validates the result and writes one artifact per platform.

  • Web: CSS custom properties, plus a typed TypeScript module.
  • iOS: a Swift package with Color and Font extensions.
  • Android: a Kotlin module and XML resources.
Code in a dark editor showing SVG markup with linear gradients
Generated output is checked in, so a token change always shows up in review.Photograph via Unsplash

Guardrails that paid off

The most valuable part of the pipeline isn't the generation, it's the validation. The build fails if a text/background pair drops below WCAG AA contrast, if a token is referenced but undefined, or if a primitive is used directly in product code.

What we'd tell a team starting out

Start smaller than you think. Two or three categories, one platform and the validation script is enough to learn what your team actually needs. The mistake we made early was modeling every possible theme before shipping a single token.

Written by

Priya Raman

Head of Design

Priya leads product and brand design. She is interested in the unglamorous parts of interfaces: empty states, error messages and the second visit.

Keep reading

All stories