Design tokens: naming colour, type and spacing so they last
What design tokens are, why to name them by role rather than by value, and how they carry a design system into code.
A design token is a named design decision: primary instead of a hex value, space-4 instead of 16 pixels. Designers and developers both use the name, so when a value changes it changes everywhere the name is used: in the design file, in the documentation and in the code.
Name by role, not by value
A token called blue-500 describes a colour; a token called primary describes a job. Products change their brand colour far more often than they change what a primary button is for, so names that say what a value is for survive a redesign.
- Base values are the options: a colour family from its lightest to its darkest shade, a spacing scale, a set of type sizes.
- Role tokens are the decisions: primary, text, text-muted, surface, border, danger. Each points at a base value, and components use only these.
Scales that leave room
- Spacing: choose one base unit, 4 or 8 pixels, and build the scale from it. A value outside the scale is a sign that something needs a decision.
- Type: a short set of styles, each with a fixed size, weight and line height, rather than a free choice of sizes on every screen.
- Colour: enough shades in each family to cover backgrounds, borders, text and states, with the contrast of every text pairing checked.
Light and dark from one set of names
With role tokens, a dark theme is a second set of values for the same names: surface becomes dark, text becomes light, and no component has to change.
From tokens to code
Tokens reach code as named values (CSS custom properties, Sass variables, or constants in a mobile app), so a developer writes the name of a decision instead of copying a value from a screenshot. When the value changes, the code follows.
How it works in Structura DS
Colours, type styles, spacing and grids are kept as named items in a project's library, imported from Figma's styles and variables or a Sketch file, brought in from a DS Library theme, or added by hand. Export design tokens, in the project's menu, hands them to developers as W3C JSON, CSS variables, SCSS, a Tailwind CSS v4 theme or a Tailwind CSS v3 config. System preview draws real web and mobile templates from them, and the code it gives you in HTML, CSS, SCSS, React and React Native is written in your tokens rather than hard-coded values.