# Design tokens

> Give a canvas named colours, spacing, radii and type — CSS variables every frame and every agent uses — with a value per theme, bound from the Design panel and exported as CSS, Tailwind or markdown.

Source: https://doop.design/docs/tokens

Variables for a canvas — colours, spacing, radii and type that every frame and agent shares.

A design token is a named value a canvas owns: `color-primary`, `radius-card`, `font-heading`. Frames use it as an ordinary CSS variable, `var(--color-primary)`, so changing the token once restyles every frame that names it — the person who edits in the Design panel and the agent that writes HTML over MCP are reading the same list. Tokens carry a value per **theme**, so one frame can switch to dark, compact or a brand variant without a second copy of the design. If you have used variables in Figma or tokens in Paper, this is the same idea.

## What a token is

Every token has a **type**, a **name**, a **value** and an optional note on when to reach for it. There are eleven types, in three groups:

- **Colour** — color, opacity, radius.
- **Layout** — spacing, container, breakpoint.
- **Type** — font family, font weight, font size, line height, letter spacing.

Names are typed without the leading dashes (`color-primary`) and used in CSS with them (`var(--color-primary)`). Letters, digits, hyphens and underscores are allowed; spaces become hyphens. A name is unique on its canvas, and a canvas holds up to 500 tokens.

A value is one CSS value — `#0177d3`, `12px`, `'Inter', sans-serif`, `1.4`. It can also be `var(--other-token)`, which **aliases** another token on the same canvas: `color-button` pointing at `color-primary`, say. Aliases must resolve, and a token another token aliases cannot be deleted until the alias is repointed.

## Create and edit tokens

Open the **Layers** panel and switch to its **Tokens** tab (the braces icon; the collapsed rail has the same button). The tab lists the canvas's tokens folded by type, like frames in the layer tree. Press **+** beside the Tokens heading, pick a type, and the new token opens with a suggested name (`color-2`, `radius-1`) and a default value for its type. Each type gets a fitting control: a swatch and hex field for colours, font and weight lists for type, a number with its unit for everything else — drag the glyph at the left of a number to scrub it, as in the Design panel. Enter saves.

![The Layers panel on its Tokens tab, listing default and dark themes and colour, radius, spacing and type tokens, beside a pricing frame in its light and dark theme](https://doop.design/docs/tokens/tokens-panel.jpg)

The Tokens tab: themes on top, tokens folded by type. The same frame renders in both themes.

Click a token to edit it, rename it, add a note, or delete it. A **rename** rewrites every `var(--old-name)` in every frame and in any token that aliased it, so nothing breaks. A **delete** leaves frames naming the token; they fall back to whatever default they wrote until a token of that name exists again.

![The Edit Color token dialog for color-primary with a default value, a dark theme value and a usage note](https://doop.design/docs/tokens/token-modal.png)

Each theme gets its own value row. The note under Use is what agents read too.

### Bind a field in the Design panel

You rarely need the Tokens tab to use a token. Select an element and the Design panel's **fill**, **stroke** and **text colour**, **corner radius**, **font size**, **font family** and **font weight** fields each carry a braces button — it appears over the field's unit on hover, or beside the font selects. Click it to pick from the canvas's tokens of that kind; the field now writes `var(--name)` and shows the token as a chip with its resolved swatch. The broken-chain button beside the chip detaches it back to the literal value.

![The token menu opened from the Fill field in the Design panel, listing the canvas colour tokens with swatches and values](https://doop.design/docs/tokens/token-menu.png)

The braces button on Fill opens the colour tokens. The + makes a new one from the current value.

The same menu has a **+**: it takes the field's current value, asks for a name, and creates the token and binds the field in one step — Figma's "create variable from this fill", for any of the seven fields.

## Themes

Every canvas has a `default` theme, the value you set first. Up to eight more — `dark`, `compact`, `brand-b`, any lowercase slug — give a token a second value where it should differ. The token editor shows a value row for `default` and one for each theme; clear a theme’s value with the ✕ beside it and it follows the default again. A theme is declared the first time a token names it, or from the **Themes** heading's **+** in the Tokens tab. Right-click a theme row to rename it (its values follow) or delete it (its values go with it).

A frame picks its theme with one attribute on its root: `<html data-doop-theme="dark">`. Put the same attribute on a subtree to theme only part of a frame. On the canvas, selecting a theme row in the Tokens tab switches the selected frames to it — or every frame on the page when nothing is selected — one undo step per frame.

## How frames carry tokens

A frame is always a self-contained HTML document, so Doop writes the values of the tokens a frame names into a managed `<style data-doop-tokens>` block at the top of its `<head>`: a `:root { … }` rule with the defaults, then one rule per theme with its overrides. Screenshots, exports and anything else that reads the frame's HTML get the right values with no extra lookup.

When a token changes, Doop rewrites that block in every frame on the canvas that names it. This is a restyle, not a redesign: a frame marked [ready for dev](https://doop.design/docs/handoff) keeps its sign-off, no [version](https://doop.design/docs/handoff#version-history) is filed, and the activity feed gets one line naming the token and how many frames followed. Leave the block alone — it is regenerated on every save.

## Tokens for agents

An agent connected over [MCP](https://doop.design/docs/get-started) sees the canvas's tokens and themes in `get_canvas`, with a brief telling it to use `var(--name)` rather than literal values, and has four tools of its own. The [Doop Agent](https://doop.design/docs/doop-agent) has the same four.

- `get_tokens` — the list, filtered by `types` or a `name_pattern` glob, as JSON or rendered as `css`, `tailwind` or `markdown`.
- `create_tokens` — add one or many tokens at once; the payload matches Paper's `create_tokens`, so an agent that knows Paper's tokens knows Doop's.
- `set_tokens` — change values, descriptions and per-theme values, rename with `new_name`, or `delete`.
- `set_token_themes` — the canvas's theme list: add, rename or remove themes in one call.

A brief that leans on tokens tends to produce consistent work across many frames and agents:

```
Set up tokens for this canvas from the imported homepage — a colour scale, a 4px
spacing scale, two radii and the type ramp — with a dark theme. Then rebuild the
pricing page using only tokens, no literal colours or sizes.
```

## Export tokens to code

Tokens are meant to leave the canvas. Three formats are available from the REST API and from `get_tokens`:

- **CSS** — the same `:root` and theme rules the frames carry, ready to paste into a stylesheet.
- **Tailwind** — a Tailwind v4 `@theme` block. Token names follow Tailwind's namespaces (`--color-*`, `--spacing-*`, `--radius-*`, `--font-*` …), so the export is a pass-through and `bg-primary` or `rounded-card` just work.
- **Markdown** — tables per type with every theme's value and the note, for a design doc or a PR.

```sh
# JSON by default; ?format=css | tailwind | md
$ curl https://doop.design/api/canvases/<canvas-id>/tokens?format=tailwind
# tokens as tables + the :root CSS, followed by every style guide on the canvas
$ curl https://doop.design/api/canvases/<canvas-id>/styleguide.md
```

`styleguide.md` is the one file a coding agent needs: the tokens as tables, the CSS block, then every [style guide](https://doop.design/docs/get-started#style-guides-and-references) written on the canvas. Drop it into a repo as its `DESIGN.md` and the implementation starts from the same values the design used.

## Tips

- **Name by role, not by value.** `color-surface` survives a rebrand; `color-grey-100` does not. Keep raw scales as aliased targets if you want both.
- **Use a font-family token** for your brand face. A [library font](https://doop.design/docs/fonts) named only through a token is still embedded in every frame that uses it.
- **Theme the few tokens that differ.** A dark theme is usually ten colour overrides; everything else inherits the default and stays greyed in the Tokens tab.
- **Pair tokens with a style guide.** Tokens say what the values are; a guideline says when to use them. Agents read both before they design.
