Design Tokens as Code: One Source of Truth for Every Platform
Why design tokens belong in code, and how they stop drift across teams and platforms.
The drift problem
Every design system starts unified and slowly drifts. A button hex code gets copy-pasted, a spacing value gets nudged 'just this once', and six months later the product has seventeen slightly different grays. Design tokens are the fix: a single, versioned source of truth that every platform consumes.
Store tokens as data — a JSON or TypeScript module — and generate the platform outputs: CSS custom properties for web, and whatever your native or mobile layers consume.
Tokens are an API
Treat tokens like a public API: semantic names, versioned releases, and a changelog. `--color-primary` is a contract; `#22d3ee` is an implementation detail. Consumers should never hardcode values, because the moment they do, the system forks.
Add type generation so a renamed or removed token becomes a compile error, not a silent styling bug. The compiler is your design-system police.
Start small, stay disciplined
You don't need a full token pipeline to start. Begin with colors and spacing, wire them into your build, and expand as the team feels the benefit. The discipline matters more than the tooling.