Skip to main content
L Lenny

Building a small design system, part 1: Tokens

Lenny 1 min read

A design system doesn’t start with a button. It starts with the decisions every button, card and page will share: color, spacing, type and radius. Those decisions are your tokens.

One file, many outputs

Keep tokens in one place and generate everything else from it:

{
  "color": {
    "primary": { "value": "hsl(22 74% 48%)" },
    "background": { "value": "hsl(36 18% 97%)" }
  },
  "radius": { "tile": { "value": "1rem" } }
}

From that file you can produce CSS variables for the site, typed constants for your scripts, and styles for your design tool. When a color changes, it changes everywhere in one commit.

Name by role, not by value

--primary survives a rebrand. --orange-500 doesn’t. Name tokens after what they do, and dark mode becomes a second set of values for the same names.

Series in this theme

This post is part 1 of a series. Posts that share a series.slug in their frontmatter are grouped on the journal page and linked together, with part numbers and next and previous links.