Design tokens
Design tokens are named values for a design's smallest decisions, such as colours, font sizes and spacing, stored once and used everywhere.
Instead of writing #ff5900 in forty places, you define a token like --orange once and refer to it. Change the token and the whole site follows. Tokens can also carry meaning: --text-secondary says what a colour is for, not just what it is.
Tokens are the bridge between design tools and code. The W3C Design Tokens Community Group has published a common file format so tokens can move between tools such as Figma and a codebase.
How Regular approaches it
Each Standard site has one tokens file. Rebranding a client site starts there: fonts, colours, radii and spacing, and the components pick them up. We keep the number of tokens small enough that someone can read the whole file.
Sources and further reading
- Design Tokens Community Group, W3Cw3.org
- Using CSS custom properties, MDN Web Docsdeveloper.mozilla.org