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.
{
"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
ColorandFontextensions. - Android: a Kotlin module and XML resources.

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.



