Build radar
Sources 33Updates always the freshest
0 Newsletter
Animated illustration for: Design to code: tokens, components and a shared language with AI
Create · Design → code · Explainer · 9 min read

Design to code: tokens, components and a shared language with AI

Why design tokens and a component library make AI generate a consistent interface. The DTCG standard, Tailwind theme variables and shadcn/ui components.

In short
  • Design tokens are named decisions: colours, spacing, typography, which you record once and use everywhere.
  • When AI gets tokens and a component library, it generates an interface consistent with your style instead of a random one.
  • The Design Tokens standard (DTCG) has a stable 2025.10 version, which eases exchange between tools.

When you ask AI for an interface, without extra constraints you get something that looks good, but each following screen is slightly different: another shade of blue, other spacing, another corner radius. Everyone who tried to build a consistent site from a series of independent prompts knows this phenomenon. The remedy is the same as design teams have used for years: design tokens and a component library. They give AI a shared language in which it makes its decisions.

What design tokens are

A design token is a named decision about appearance: an accent colour, a background colour, a spacing scale, font sizes, a corner radius, a shadow. Instead of typing a hex value in fifty places, you record it once under a name and use the name everywhere. Changing a theme is then changing one value. Tailwind’s documentation puts it this way: different projects need different typography, colours, shadows or breakpoints, and these low-level decisions are called design tokens. In Tailwind you store them in theme variables, defined with the @theme directive; they influence which utility classes exist in the project, and ordinary CSS variables are also generated that you can refer to.

The formal standard for exchanging tokens is handled by the Design Tokens Community Group. On the group’s site the first stable version of the specification, 2025.10, is announced, together with a JSON format meant to provide interoperability and theming between tools. The list of participants includes Figma, Penpot, Sketch and Style Dictionary, among others. For you the conclusion is practical: tokens stored in an open format can be moved between a design tool and code.

A component library as the second constraint

Tokens define values, but not recurring elements such as a button, a form field or a card. A component library helps here. shadcn/ui describes itself as a set of beautifully designed, accessible components and a code distribution platform. Components land in your project as code you can modify, and the documentation also mentions integration with AI tools: there is an MCP server, component registries and the ability to open a component in v0. When you tell an agent to use components from the library and tokens from the theme, its freedom drops and consistency rises.

What constrains AI and why
What you recordEffect for AI
Colour tokensNamed brand and state coloursNo invented shades
Spacing and typography scaleA few sizes instead of arbitrary onesA consistent layout rhythm
ComponentsButton, field, card in one styleRepeatable interface elements
Rules in the instruction fileRules for using tokens and componentsCompliance with the system on every screen

How to pass the system to AI

The most effective way is to record the system in project files. Keep tokens in a single theme file. Components in one directory. In the agent’s instruction file, such as CLAUDE.md, add a few sentences: use only tokens from the theme, do not type colour values in code, build screens from library components, and add a new component only when none fits. I describe the details of such a file in the article on Claude Code configuration. Describe accessibility rules as well, for example minimum contrast, because otherwise the agent will optimise looks at the expense of legibility.

  1. 01
    DecisionsColours, spacing, typography, radii.
  2. 02
    TokensNamed variables in one theme file.
  3. 03
    ComponentsA library or your own set.
  4. 04
    InstructionRules of use written for the agent.
  5. 05
    GenerationScreens from tokens and components.
  6. 06
    ReviewCompliance, contrast, consistency.

When you do not have a system yet

You do not need to start with a full system. A small version is enough: five colours, three spacing sizes, two text sizes, one font family and three components. Record them as CSS variables, ask AI to build a page solely from them and judge the result. Such a small system grows with the project. The most common mistakes are three things. Too many tokens at the start, half of which nobody uses. Names that describe the value rather than the role, for example “blue-500” instead of “accent”, which makes later theme changes harder. No rules of use, so the agent hard-codes colours anyway. It is good to name tokens by role, keep few of them and now and then search the code for values that should be tokens.

An example of work from a mockup to a working component is in the article From a mockup to a component, and the whole topic is in the Design → code hub.

Last checked: 20 October 2026. Standards and libraries change quickly; check the documentation before use.

Frequently asked questions

What is a design token?
A named design decision, for example an accent colour, a spacing scale or a font family, stored in one place and used across the interface instead of repeated values.
Why do tokens help with AI?
Because the model gets a limited, named set of values instead of freedom. Instead of inventing a colour, it will use the accent variable, and the interface stays consistent.
Must I use Tailwind?
No. Tokens can be stored in plain CSS variables. Tailwind introduces theme variables that additionally generate utility classes, which makes working with AI easier.
How does shadcn/ui differ from an ordinary library?
According to the documentation it is a set of components and a code distribution platform: you copy the components into your project and can modify them instead of importing from a locked package.

Sources

Design → code

Related