# Design tokens

Design tokens are the named values a user interface is built from: colours, type sizes, spacing, radii, shadows and animation lengths, kept in one place and used by name. A change to a token reaches every screen that uses it, in both themes. In Meadowstack the colour tokens are generated from two inputs, and a guard fails the build when code types a colour itself.

Checked 2 December 2026. By Bohuslav Poláček. https://meadowstack.com/glossary/design-tokens/

*Every colour of the kit comes from these inputs: the page colour per theme and one contrast value.*

From `packages/kit/src/tokens/inputs.ts` in the Meadowstack repository:

```ts
 * 7 Nov 2026 (docs/decisions/0012-greyscale.md): back to pure grey, chroma 0, for the apps and the website alike.
 * The warm tint read as cream in the apps and as beige on the site (Bob, 4 and 7 Nov 2026), and the second
 * "neutral" palette that hid it on the website is gone: one greyscale everywhere.
 *
 * There is deliberately no accent or brand colour: the kit is neutrals,
 * status colours and the categorical hues that carry identity and data
 * (palette.ts). A client brand goes in a client theme (skill kit-theme).
 */
import type { PaletteInputs } from "./palette.ts";

export const meadowstackInputs: PaletteInputs = {
  base: {
    light: "oklch(1 0 0)",
    dark: "oklch(0.155 0 0)",
  },
  contrast: 0.5,
};
```

## Why it matters in a business app

An internal app grows screen by screen: orders this month, approvals the next, a supplier record after that. Without tokens each screen picks its own grey, its own 14px and its own corner, and after a year the app has eleven greys and three table looks. With tokens the order table and the approval queue share one hover colour and one row height because they ask for the same names.

Tokens also make the second theme and a client's brand possible at all: dark mode is the same names with other values, not a second stylesheet.

## How Meadowstack handles it

- **Colours are generated.** `packages/kit/src/tokens` turns the page colour of each theme and one contrast value into every neutral, every text level and the focus ring, in [OKLCH](https://meadowstack.com/glossary/oklch/). `npm run tokens` writes `palette.css`; nobody edits it by hand, and a unit test fails when it is stale.
- **The rest is written once.** Radii, shadows, type sizes and motion lengths live in `packages/kit/src/styles/tokens.css`: product text 13/20, meta 12/16, controls 32px, an entering element 160ms, a leaving one 120ms.
- **No way around them.** The default Tailwind palette is off, so its stock colour classes (blue-500 and the rest) do not exist. `npm run check:tokens` fails on hex, rgb, hsl or oklch in components, classes and inline styles, and a Claude Code hook runs it after every edit.
- **The rule for agents.** AGENTS.md says "Never invent a size; add a token", which is what stops a coding assistant from typing `text-[15px]`.

## Common mistakes

- **Naming tokens by their look.** `blue-500` says nothing about where it may go. Name by role, see [semantic colour tokens](https://meadowstack.com/glossary/semantic-color-tokens/).
- **A token per screen.** Twenty tokens used once are values with extra steps. A new token earns its place when a second screen needs it.
- **Editing the generated file.** The next `npm run tokens` puts it back; change the inputs or the rule in `palette.ts` instead.

## Questions

### What is the difference between design tokens and CSS variables?

Tokens are the decisions: which grey is muted text, how long a panel takes to open. CSS custom properties are one way to deliver them. In Meadowstack they arrive as custom properties in palette.css and tokens.css and as Tailwind utilities built on them.

### How many inputs does Meadowstack's colour palette have?

Two: the page colour for each theme and one contrast value from 0 to 1. Every neutral, text level and the focus ring follow from them, and text never drops below the WCAG floors whatever the contrast value.

### Can a client's brand change the tokens?

Yes. A client theme overrides the tokens for light and dark, and the contrast guard can read that theme file to check it before it ships.

### Do design tokens help when an AI assistant writes the code?

They help only when something enforces them. An assistant copies whatever it sees, so Meadowstack pairs the tokens with a guard that fails on a typed colour and runs after every edit.

## Related

- [How to keep AI-generated UI consistent](https://meadowstack.com/guides/keep-ai-generated-ui-consistent/) (Guide)
- [AsyncState: every data view has four states](https://meadowstack.com/components/async-state/) (Components)
- [BulkBar: what to do with the selection](https://meadowstack.com/components/bulk-bar/) (Components)
- [DataTable: the table of every list](https://meadowstack.com/components/data-table/) (Components)
- [Field: the label, hint and message of every input](https://meadowstack.com/components/field/) (Components)
- [FilterBar: the one row above a list](https://meadowstack.com/components/filter-bar/) (Components)
