@designtools/tokens 0.9.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,31 @@
2
2
 
3
3
  Notable changes to `@designtools/tokens`. Dates are release dates; versions follow semver, with breaking changes in the minor slot while the package is pre-1.0.
4
4
 
5
+ ## 0.11.0
6
+
7
+ ### Minor Changes
8
+
9
+ - 07b2b90: **Grounds: content on coloured backgrounds.** A ground is a background content sits on, with every token content needs on it searched again against that background: `--canvas` and `--canvas-foreground` (the ground and its text), `--muted` and `--muted-foreground`, `--border`, `--input`, `--ring`, and for every semantic colour its fill, `-foreground`, `-hover`, `-active`, `-subdued` and `-subdued-foreground`. Mark an element `data-surface="<ground>"` and components inside need no change. On a coloured ground everything without a meaning of its own takes the ground's colour: in a success banner the button, ring, chips, panels and borders are green and the secondary button is a tonal green, while a delete button stays red; on an indigo band `bg-primary` turns white with an indigo label. Every pairing is contrast-checked on the ground. The grounds are `canvas` and `surface` (the page's own values, to reset a card inside a band), `success-subdued`, `warning-subdued` and `destructive-subdued` (banners and alerts), and every `--background`. Neutral grounds keep the page's tokens wherever they work. `--report` lists what each ground changed and anything it couldn't reach. `--grounds text` (`"grounds": "text"` in a seed) makes a ground its background and text only, everything else staying the page's; `--grounds none` leaves grounds out.
10
+
11
+ Emitted as `--on-<ground>-<token>` in each mode block, only where a ground differs from the page, and one `[data-surface]` scope per ground after the mode blocks; `tailwind-v4` re-binds its `--color-*` aliases inside each scope, and DTCG carries them as `<mode>.ground.<name>`. `--only grounds` selects them; a family-scoped run (`--ramps`) leaves them alone, as it does surfaces. `TokenSystem.grounds` carries them in code. Existing output is unchanged; grounds are added to it, so a default CSS file grows from about 270 lines to about 900 (about 330 with `--grounds text`).
12
+
13
+ A `--background` name a token or ground already uses (`canvas`, `primary`, `warning-subdued`, …) is now refused, unless `--grounds none`. The README explains the three ways to add a colour: `--color` (a ramp and semantic tokens), `--color` with `--decorative` (a ramp only), and `--background` (a section colour and its ground).
14
+
15
+ Fix: `--merge` with an `--only` slice that has no primitives (`--only semantic`, `--only grounds`) reported its blocks as missing, because braces quoted in the file's header comment were read as a block.
16
+
17
+ ## 0.10.0
18
+
19
+ ### Minor Changes
20
+
21
+ - 93dd9ed: Colours are edited in place on the docs' colour page: `ColourGenerator` floats a bar bottom right there (Edit colours, then Copy prompt, reset, light and dark, and settings) and adds nothing to the dock. With editing on, each ramp opens its colour and anchor step, its own shape and exact colours for single steps, over the project's ramp; each colour its fill and subdued step (only steps whose label passes); and the settings the whole system's options, a link carrying the settings and saved versions. Explanations are tooltips.
22
+
23
+ New generator controls, inputs to the maths rather than colours picked by hand, as flags and seed fields, all unchanged output when unset: `--light-end`/`--dark-end` (`lightnessRange`) and `--tint-floor` (`tintFloor`) for where the colour ramps end and how much colour their pale steps keep; `--chroma`, `--chroma-strength` and `--chroma-peak` (`chroma`) for colourfulness profiles; `--hue-drift` (`hueDrift`); `"families"` in a seed for one colour leaning away from the system; `--pin family@step=colour` (`pins`) for an exact colour on a step, refused with the reason when it would put the ramp out of order or off the screen; and `--contract`, which prints where a step number means something different in one colour than in the rest (`stepContract` in code). The neutral keeps its own shape unless named. `--no-aliases` (`"aliases": false`) emits each status ramp once, without green, red and yellow beside success, destructive and warning; the default is unchanged. The colour editor's copy buttons work on a dev server opened by its network address.
24
+
25
+ ### Patch Changes
26
+
27
+ - Updated dependencies [7005847]
28
+ - @designtools/widgets@0.1.4
29
+
5
30
  ## 0.9.0
6
31
 
7
32
  ### Minor Changes
package/README.md CHANGED
@@ -42,13 +42,13 @@ From a single seed colour:
42
42
 
43
43
  Every `-foreground` is chosen by rule and measured, not a fixed mapping (see [Foregrounds](#foregrounds-are-chosen-by-what-they-sit-on)). Hover and press are `--primary-hover` and `--primary-active` (see below). `highlight`, which sat two steps from the fill and read as pressed rather than hover, was removed in 0.7.0.
44
44
 
45
- **Surfaces and utilities** — `--canvas`, `--surface`, `--overlay` with paired foregrounds, plus `--border`, `--input`, `--ring`, `--shadow`. The three backgrounds default to neutral steps and take exact colours per mode (`--canvas "#F2F2F0/#12171D"`); a brand's other section backgrounds come in by name (`--background stone=#E8E8DB`) as `--surface-stone` with measured text.
45
+ **Surfaces and utilities** — `--canvas`, `--surface`, `--overlay` with paired foregrounds, plus `--border`, `--input`, `--ring`, `--shadow`. The three backgrounds default to neutral steps and take exact colours per mode (`--canvas "#F2F2F0/#12171D"`); a brand's other section backgrounds come in by name (`--background stone=#E8E8DB`) as `--surface-stone` with measured text, and as a [ground](#grounds-content-on-coloured-backgrounds).
46
46
 
47
47
  **Hover and press are generated.** Each fill gets `--<name>-hover` and `--<name>-active`: the fill moved 0.09 and 0.15 in lightness away from its label (darker under a white label, lighter under a black one), so the change is plain to see and the label reads better on it, never worse. The 90% opacity they replace was barely visible (median ΔE 4.7) and dropped 26 of 90 labels under 4.5:1 by letting the page show through.
48
48
 
49
49
  **Status text on the page is the subdued label.** `--success-subdued-foreground` and its siblings are guaranteed to read as text on every background of their mode, so an error message is `text-destructive-subdued-foreground`, not `text-destructive` (the fill, measured only against its own label). A warning on the page is neutral text with an icon: warning is an orange, and orange dark enough to be text reads as brown. In light mode warning, and any yellow or orange brand colour, carries its hue in a stronger tint (step 200) with a near-black label for the same reason.
50
50
 
51
- **Every colour against every background.** A label is checked on its own fill; `pageContrast` (and `--report`) measures the rest: each semantic fill and muted text against the canvas, surface, overlay and each named background, per mode, so red text on a dark page (2.4:1 for every brand tested) or a deep purple button on a dark canvas (1.2:1) shows up before it ships. Read it as text (4.5:1 at AA) or as a shape (3:1, WCAG 1.4.11): a button's own label makes its outline optional, a meter fill or a switch has no label to lean on.
51
+ **Every colour against every background.** A label is checked on its own fill; `pageContrast` (and `--report`) measures the rest: each semantic fill and muted text against the canvas, surface, overlay and each named background, per mode, so red text on a dark page (2.4:1 for every brand tested) or a deep purple button on a dark canvas (1.2:1) shows up before it ships. Read it as text (4.5:1 at AA) or as a shape (3:1, WCAG 1.4.11): a button's own label makes its outline optional, a meter fill or a switch has no label to lean on. This measures the page's tokens where they land; inside `data-surface` a [ground](#grounds-content-on-coloured-backgrounds) gives content tokens chosen for that background instead.
52
52
 
53
53
  **Light and dark**, derived independently from the same ramps rather than one being a transform of the other, with contrast re-checked per mode. Output is keyed on `[data-theme]` with a `prefers-color-scheme` fallback, so it works with or without a theme toggle:
54
54
 
@@ -59,6 +59,93 @@ Every `-foreground` is chosen by rule and measured, not a fixed mapping (see [Fo
59
59
  @media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { … } }
60
60
  ```
61
61
 
62
+ ## Adding colours: three flags, three jobs
63
+
64
+ Beyond the primary and the neutral, a colour comes in one of three ways. They do different jobs; pick by what the colour is for, not by what it looks like.
65
+
66
+ | You have | Flag | You get | Use it for |
67
+ |---|---|---|---|
68
+ | A colour things are made **in**: a second brand colour, a category colour | `--color teal=#14b8a6` | A ramp (`--color-teal-25` … `-950`) **and** semantic tokens: `--teal`, `-foreground`, `-subdued`, `-subdued-foreground`, `-hover`, `-active`, each label contrast-checked | Buttons, badges, tags, text in that colour |
69
+ | A colour that must **never** be text or an action: an illustration tint, a chart accent | `--color sand=#e8d5b0 --decorative sand` | The ramp only. No `--sand`, no `bg-sand`, so it cannot end up as a label or a button by accident | Decoration, data viz, artwork |
70
+ | A colour a whole **section** is painted with: a band on a marketing page | `--background brand=#4f46e5` | One exact colour, `--surface-brand`, with measured text, **and a ground**: inside `data-surface="brand"` every token is searched again against it ([below](#grounds-content-on-coloured-backgrounds)) | Page sections, hero bands, footers |
71
+
72
+ `--background` takes the colour exactly as given and makes no ramp from it; if you also want a scale in that colour, add it with `--color` as well. A background name can't be one a token or ground already uses (`canvas`, `surface`, `primary`, `warning-subdued`, …): each one becomes a `data-surface` value and a token prefix, so a clash would put two things under one name. The generator refuses it and says which names are taken.
73
+
74
+ ## Grounds: content on coloured backgrounds
75
+
76
+ The page tokens are searched against the canvas, the surface and the overlay. Content sits on other backgrounds too: a warning banner with a button in it, an indigo band on a marketing page with a caption and a call to action. On those, the page's tokens were only ever measured, never chosen, and a primary button on a primary band is 1:1.
77
+
78
+ A **ground** is a background content sits on, with every token content needs on it searched again against that background. Mark the element once and components inside need no change:
79
+
80
+ ```html
81
+ <section data-surface="brand">
82
+ <h2>Book your first session</h2>
83
+ <p class="text-muted-foreground">Readable on the band, quieter than the heading</p>
84
+ <button class="bg-primary text-primary-foreground">Get started</button> <!-- turns white, label indigo -->
85
+ <div class="bg-surface" data-surface="surface">A card resets to the page's own tokens</div>
86
+ </section>
87
+
88
+ <div data-surface="success-subdued">A banner: <button class="bg-primary …">this button is green here</button></div>
89
+ ```
90
+
91
+ **Which grounds there are**
92
+
93
+ | Ground | From | Its tokens |
94
+ |---|---|---|
95
+ | `canvas`, `surface` | Always | The page's own, exactly. Use them to reset inside another ground: a card in a band is `data-surface="surface"` |
96
+ | `success-subdued`, `warning-subdued`, `destructive-subdued` | Always | Searched against the status tint: banners, alerts, inline messages |
97
+ | `<name>` | Each `--background <name>=…` | Searched against that colour |
98
+
99
+ **What each ground carries.** The same names everywhere, so a component reads the same tokens on any ground:
100
+
101
+ | Token inside the ground | For | Must reach |
102
+ |---|---|---|
103
+ | `--canvas`, `--canvas-foreground` | The ground and its body text | the ground's own text (a status tint's label, a band's measured text) |
104
+ | `--muted`, `--muted-foreground` | Panels, captions, supporting copy | text at 4.5:1 (7:1 at AAA) on the ground and on a muted panel, and quieter than the body text |
105
+ | `--border` | Dividers | the separation the border has on the page |
106
+ | `--input`, `--ring` | A field's edge, the focus ring | 3:1 (WCAG 1.4.11) |
107
+ | `--<colour>`, `-foreground`, `-hover`, `-active` | Buttons, for every semantic colour | the fill stands out from the ground at 3:1; its label reads on it |
108
+ | `--<colour>-subdued`, `-subdued-foreground` | Chips, and that colour's text on the ground (an error under a field) | the label reads on the tint and on the ground |
109
+
110
+ **The rule: everything takes the ground's colour, except what carries a meaning.** On a coloured ground (a status tint, or a band with real colour) the primary button, the focus ring, chips, links, panels, borders, input edges and secondary text all come from the ground's own ramp, and the neutral button becomes a tonal one in that hue: in a success banner the button and ring are green, on an indigo band indigo. Status colours keep their meaning, so a delete button is still red in a success banner. Each value is the ground's page token where that reads on the ground (a success banner's button is `--success`), and searched along the ramp where it doesn't. On its own colour a button turns over: on the brand band the primary button is the ramp's palest step with the brand colour in its label. A neutral ground (the canvas, the surface, a stone or near-grey band) keeps the page's tokens wherever they work.
111
+
112
+ **What it can't do, it says.** `--report` lists what each ground changed from the page and anything its search couldn't reach. Two you will see:
113
+
114
+ - On a light success or destructive banner the body text is already the tint's label at about 6:1, so no quieter step still reads at 4.5:1, and the muted text is the body colour.
115
+ - On a saturated band, status text has to be near white to read, so red text on an indigo band is a very pale red. Let the icon carry the meaning.
116
+
117
+ **Not part of a ground:** `--surface`, `--overlay` and their foregrounds (a card is still a card, on any band), `--shadow`, and the ramps.
118
+
119
+ **How it's emitted.** Each ground's tokens sit in the mode blocks as `--on-<ground>-<token>` (`--on-brand-primary`, `--on-warning-subdued-muted-foreground`), only where they differ from the page; the rest read the page's copy, `--on-canvas-<token>`. After the mode blocks, one scope per ground re-points the everyday names and paints the ground:
120
+
121
+ ```css
122
+ [data-surface="brand"] {
123
+ --primary: var(--on-brand-primary);
124
+ --muted-foreground: var(--on-brand-muted-foreground);
125
+ /* … every token the ground carries … */
126
+ background-color: var(--canvas);
127
+ color: var(--canvas-foreground);
128
+ }
129
+ ```
130
+
131
+ Because the values live in the mode blocks, a ground follows `data-theme` and `prefers-color-scheme` like everything else, and a ground nested in another (a banner inside a band) reads its own values, not its parent's. The `tailwind-v4` format re-binds each `--color-*` alias inside the scope too, for [the reason the mode blocks do](#tailwind-v4), so `bg-primary` follows the ground.
132
+
133
+ **Changing one token on one ground** is ordinary CSS after the generated file, unlayered (see [Overriding](#overriding-what-it-generates)). It applies in both modes, because the scope reads the mode's value:
134
+
135
+ ```css
136
+ [data-surface="brand"] { --neutral: transparent; --neutral-foreground: var(--color-white); }
137
+ ```
138
+
139
+ **How much a ground carries: `--grounds`.**
140
+
141
+ | `--grounds` | Inside `data-surface` | Default CSS file |
142
+ |---|---|---|
143
+ | `full` *(default)* | Every token above, tinted to the ground and contrast-checked on it | about 900 lines, plus about 150 per `--background` |
144
+ | `text` | The background and its text only; buttons, borders, the ring and the rest stay the page's | about 330 lines |
145
+ | `none` | No grounds: no `data-surface`, no `--on-*`. Each `--background` is `--surface-<name>` and its text, painted with classes | about 270 lines, as before grounds |
146
+
147
+ With `text`, the page's tokens are not checked against the ground: a blue button in a dark green banner can fall under 3:1, and `--report` still measures it. To keep `full` but put one token back to the page's, read the page's copy: `[data-surface="success-subdued"] { --primary: var(--on-canvas-primary); }`.
148
+
62
149
  ## Try it
63
150
 
64
151
  ```bash
@@ -180,19 +267,42 @@ export function ScalesTool() {
180
267
  }
181
268
  ```
182
269
 
183
- ## Trying new colours: the colour generator
270
+ ## Editing colours in place: the colour generator
271
+
272
+ Designers change the inputs to the maths, never its outputs. `ColourGenerator` edits the colours on the docs' colour page itself, which is where you look at them, and the page keeps its layout. A bar floats bottom right on that page (local dev and previews only): **Edit colours**, and once editing, Copy prompt with the number of changes, then adding a colour, reset, light and dark for the page and the tools, and the settings, then Done. With editing on, each ramp and each colour gets a small button that opens its settings in place:
273
+
274
+ - **A ramp** (the swatch by its name): the ramp now over the project's own; the colour it's made from and the step that colour lands on (a status colour set by hand or left to follow the primary, an added colour renamed or removed); its own shape when it leans away from the system's; and exact colours for single steps.
275
+ - **A colour** (Steps, by its ring): which step its fill and its subdued sit on, in light and dark, chosen only from steps whose label passes; hover one for its contrast.
276
+ - **The whole system** (the bar's settings): the score; the contrast method and target, lightness and labels on fills; the shape all ramps share; a link carrying the settings; and saved versions.
277
+
278
+ Every change regenerates in the browser and re-themes the page, every open tab and every artboard. A setting the generator refuses (a pin out of order) is said plainly and not applied; the page keeps the last colours it could make. Copy prompt hands back what changed, the seed and the exact command, so the generator stays the source; reset puts the project's colours back. Colour adds nothing to the design tools dock: the dock appears only for a tool asked for on that page.
184
279
 
185
- `ColourGenerator` is the generator's own inputs as a tool in the dock: the primary and neutral first, any colours to add (named, removable), then how it generates (contrast method and target, lightness, labels on fills, the step the primary lands on), with the score in both modes. It starts from the project's seed, re-themes the page and every artboard as you change it, and the docs' colour page follows, added colours included. Copy prompt hands back the seed and the exact command, so the generator stays the source; reset puts the project's colours back.
280
+ **A link carries the settings**: Copy a link with these colours puts them in the address's `#`, so "look at it with these" is a link someone opens on a preview; nothing reaches the server. **Versions** are kept in the browser, to compare before handing one back.
186
281
 
187
282
  ```tsx
188
- // a server component on the page it was asked for (the docs' colour page, say), inside the app's <Widgets>
283
+ // once, in the layout, inside the app's <Widgets>; off in production
189
284
  import { ColourGenerator } from "@designtools/tokens/studio";
190
285
  import { readProjectSeed } from "@designtools/tokens/studio/next";
191
286
 
192
- <ColourGenerator project={readProjectSeed()} />
287
+ <ColourGenerator project={process.env.VERCEL_ENV === "production" ? null : readProjectSeed()} />
193
288
  ```
194
289
 
195
- On the docs, put it on the colour page with `extras: { colour: <ColourGenerator project={readProjectSeed()} /> }`.
290
+ It fills the empty anchors `@designtools/docs` leaves on its colour page (`data-designtools-slot="colour:page"`, `"colour:ramp"`, `"colour:family"`); a page without them gets nothing but the live preview.
291
+
292
+ ### The shape of the ramps
293
+
294
+ Four levels, broadest first, each an input to the maths rather than a colour picked by hand:
295
+
296
+ 1. **The whole system**: the range, the tint floor, colourfulness and hue drift, below.
297
+ 2. **One colour**: the same settings written as differences, in a seed's `"families"` (`{ "twilight": { "chroma": { "strength": 1.5 } } }`). The neutral takes the system's shape only from here.
298
+ 3. **One step**: a pin, `--pin camel@300=#B7B7A3` (repeatable) or `"pins"`, for a colour that has to be exact. The steps between it and the seed bend to pass through it. A pin that puts the ramp out of order, sits on the seed's own step, or can't be shown on screen is refused with the reason.
299
+ 4. **The roles**: which step a fill and a subdued sit on, from steps whose label passes (`--overrides`, or the colour page's Steps).
300
+
301
+ `--light-end` and `--dark-end` set where every colour ramp ends, as OKLCH lightness in percent (default 98 and 15). A brand that only uses soft deep tones raises the dark end instead of hand-picking its darks: the steps between spread over the new range, adjacent dark steps keep at least two points between them, and the semantic searches run again, so every label still passes. `--tint-floor` (0 to 1) is how much of the seed's colourfulness the pale steps keep, as far as a screen can show it; it matters most for muted colours, whose pale steps otherwise fade to grey. `--chroma` sets how colourful each step is: `follow` (the default, easing from pale tints to the seed's chroma), `constant` (the seed's chroma throughout, as the screen allows, like Material's tonal palettes), `relative` (the seed's share of what each step's lightness can hold) or `peak` (peaking at `--chroma-peak`, falling away either side, Tailwind's shape). `--chroma-strength` scales it (0.25 to 3), eased in beside the seed so the seed's own step never moves. `--hue-drift` turns the hue in the darks: `natural` deepens yellows towards amber and blues towards indigo, as Tailwind's do, and leaves other hues; a number is degrees at 950 (`--hue-drift=-20` for a negative one).
302
+
303
+ The neutral keeps its own range, tint, colourfulness and hue, because both modes' backgrounds are made from it; name it in `"families"` to change it. In a seed: `"lightnessRange": { "dark": 34 }, "tintFloor": 0.6, "chroma": { "profile": "constant" }, "hueDrift": "natural"`. Unset, the output is exactly as before.
304
+
305
+ **The step contract.** A step number should mean the same in every colour: if 700 carries text on white in one, it should in all, so a designer can reach for "the 700" without checking. `--contract` prints each step that carries text on white, or on black, in some colours and not others. It's measured, not enforced: a yellow brand seeded on 500 breaks it by nature, and that's worth knowing rather than forbidding.
196
306
 
197
307
  ## Regenerating part of a token file
198
308
 
@@ -219,6 +329,13 @@ generate-tokens --primary "#4e9caf" --color accent=#8b5cf6 \
219
329
  --ramps accent --out tokens.css --merge
220
330
  ```
221
331
 
332
+ A family-scoped run leaves surfaces, utilities and [grounds](#grounds-content-on-coloured-backgrounds) alone: they read every family, so no one colour owns them. After regenerating a family a ground draws on, refresh the grounds the same way:
333
+
334
+ ```bash
335
+ generate-tokens --primary "#4e9caf" --color destructive=#ff0000 \
336
+ --only grounds --out tokens.css --merge
337
+ ```
338
+
222
339
  ### Why a family, and why merge
223
340
 
224
341
  A family is the right unit because **the contrast search runs inside it**. Change the ramp and the foregrounds change with it — they are chosen *against* those values. Regenerate `destructive` and this happens:
@@ -305,7 +422,7 @@ With `gamut: "p3"`, the wide-gamut tiers are on `tokens.p3`, and the checks take
305
422
  | `css` *(default)* | `tokens.css` | CSS custom properties. The lead format — works in any project. Mode blocks carry both `[data-theme]` attributes and `.dark`/`.light` classes, matching `tailwind-v4`. |
306
423
  | `tailwind-v4` | `tailwind.css` | A complete `@theme static` block. See [Tailwind v4](#tailwind-v4). |
307
424
  | `tailwind-v3` | `tailwind.config.js` | `theme.extend.colors` config. |
308
- | `dtcg` | `tokens.dtcg.json` | W3C Design Token Community Group JSON. |
425
+ | `dtcg` | `tokens.dtcg.json` | W3C Design Token Community Group JSON. Grounds sit under each mode as `light.ground.<name>.<token>`. |
309
426
  | `json` | `tokens.json` | The raw `TokenSystem`, for downstream tooling. |
310
427
 
311
428
  `--color-format` controls how literal values are printed: `oklch` (default), `hex`, `rgb`, `hsl`.
@@ -320,7 +437,7 @@ With `gamut: "p3"`, the wide-gamut tiers are on `tokens.p3`, and the checks take
320
437
  |---|---|---|
321
438
  | `--primary <colour>` | — | Your brand colour. Required unless `--seed` supplies it. |
322
439
  | `--neutral <colour>` | `#747474` | Neutral seed. Drives greys, surfaces, borders. |
323
- | `--color <name>=<colour>[@<shade>]` | — | An extra named scale. Repeatable. `@<shade>` anchors its seed on that step. |
440
+ | `--color <name>=<colour>[@<shade>]` | — | An extra named colour: a ramp and semantic tokens. Repeatable. `@<shade>` anchors its seed on that step. See [Adding colours](#adding-colours-three-flags-three-jobs). |
324
441
  | `--decorative <name>` | — | Give an added colour its ramp only, with no semantic slots (`--<name>`, `-foreground`, `bg-<name>`), so an accent that must never be text or an action cannot be used as one. Repeatable. In a seed file, `"decorative": true` on the colour. |
325
442
  | `--seed <file.json>` | — | Replay a saved configuration. Flags given alongside it win, so a seed is defaults rather than a lock. |
326
443
  | `--stdin` | off | Read that same JSON from standard input. |
@@ -354,10 +471,21 @@ A seed file:
354
471
  | `--foreground` | `balanced` · `max` | `balanced` | Labels on a fill: white or black, or a tint keeping 90% of that (`balanced`); never a tint (`max`). |
355
472
  | `--no-wcag-floor` | — | — | With `--contrast apca`, choose by APCA alone, without holding pairings to the WCAG 2 floor. |
356
473
  | `--canvas`, `--surface`, `--overlay` | `<colour>[/<dark>]` | neutral steps | The page, card and overlay as exact colours, light then dark; text on each is measured. |
357
- | `--background` | `<name>=<colour>[/<dark>]` | — | A brand section background, emitted as `--surface-<name>` with measured text. Repeatable. |
474
+ | `--grounds` | `full` · `text` · `none` | `full` | What `data-surface` gives each [ground](#grounds-content-on-coloured-backgrounds): every token tinted to it, its background and text only, or no grounds. |
475
+ | `--background` | `<name>=<colour>[/<dark>]` | — | A colour a section is painted with, emitted as `--surface-<name>` with measured text and as a [ground](#grounds-content-on-coloured-backgrounds): inside `data-surface="<name>"` every token is searched again against it. Repeatable. Names a token or ground uses are refused. Not a ramp: use `--color` for that. |
358
476
  | `--usage <file.json>` | — | — | Also write where each colour can go: every fill, status text tone and muted text on every background, per mode, as text, shape or neither (`designtools.usage/1`). `@designtools/manifest` turns the failures into measured usage rules. `--check` compares it too. |
359
477
  | `--seed-shade` | `25`…`950` | `500` | Which step your primary lands on. |
360
478
  | `--neutral-seed-shade` | `25`…`950` | `500` | Which step your neutral lands on. |
479
+ | `--light-end` | `50`…`100` | `98` | OKLCH lightness (percent) of the colour ramps' palest step. Not the neutral. |
480
+ | `--dark-end` | `0`…`60` | `15` | OKLCH lightness (percent) the colour ramps' deepest step reaches. Not the neutral. At least 30 below `--light-end`. |
481
+ | `--tint-floor` | `0`…`1` | none | How much of the seed's colourfulness the pale steps keep. Not the neutral. |
482
+ | `--chroma` | `follow` · `constant` · `relative` · `peak` | `follow` | How colourful each step is. Not the neutral. |
483
+ | `--chroma-strength` | `0.25`…`3` | `1` | More or less colour, eased in beside the seed. |
484
+ | `--chroma-peak` | `25`…`950` | the seed's step | Where `--chroma peak` peaks. |
485
+ | `--hue-drift` | `none` · `natural` · degrees | `none` | How the hue turns in the darks. Not the neutral. |
486
+ | `--pin` | `family@step=colour` | — | An exact colour on a step; the ramp bends through it. Repeatable. |
487
+ | `--no-aliases` | — | — | Each status ramp once, as success, destructive and warning, without green, red and yellow as second names for the same ramps. |
488
+ | `--contract` | — | — | Print the step contract: steps that carry text on white or black in some colours and not others. |
361
489
  | `--gamut` | `srgb` · `p3` | `srgb` | Which displays to generate for. |
362
490
  | `--shades` | `tailwind` · `full` · a list | `full` | Which steps to emit. |
363
491
  | `--overrides <file.json>` | — | — | Per-token shade overrides. |
@@ -444,7 +572,7 @@ A seed outside sRGB is reported on stderr, since its step will not be the colour
444
572
 
445
573
  | Flag | Values | What it does |
446
574
  |---|---|---|
447
- | `--only <sections>` | `ramp` · `primitives` · `semantic` · `surface` · `utility` | Emit only these tiers. Comma-separated or repeated. |
575
+ | `--only <sections>` | `ramp` · `primitives` · `semantic` · `surface` · `utility` · `grounds` | Emit only these tiers. Comma-separated or repeated. |
448
576
  | `--ramps <names>` | any colour family | Emit only these colour families. See [Regenerating part of a token file](#regenerating-part-of-a-token-file). |
449
577
 
450
578
  - **`ramp`** — the colour ramps alone. This is "hand me a colour, hand me back scales".
@@ -452,6 +580,7 @@ A seed outside sRGB is reported on stderr, since its step will not be the colour
452
580
  - **`semantic`** — `--primary`, `--destructive-subdued-foreground`, `--muted`, …
453
581
  - **`surface`** — `--canvas`, `--surface`, `--overlay` and their foregrounds.
454
582
  - **`utility`** — `--border`, `--input`, `--ring`, `--shadow`.
583
+ - **`grounds`** — `--on-<ground>-*` in each mode block and the `[data-surface]` scopes.
455
584
 
456
585
  Beyond convenience, this keeps generated colour separable from files a project hand-tunes, so re-theming does not clobber them:
457
586
 
@@ -542,7 +671,7 @@ On Tailwind v4 a token only becomes a usable class if it sits inside a `@theme`
542
671
  }
543
672
  ```
544
673
 
545
- You get `bg-primary`, `text-primary-foreground`, `bg-canvas`, `border-border` **and** `bg-primary-500`, in both modes.
674
+ You get `bg-primary`, `text-primary-foreground`, `bg-canvas`, `border-border` **and** `bg-primary-500`, in both modes, and on every [ground](#grounds-content-on-coloured-backgrounds): each `[data-surface]` scope re-binds the aliases it re-points, for the same reason the mode blocks do.
546
675
 
547
676
  Three details carry the weight, each verified against a real Tailwind compile:
548
677
 
@@ -582,6 +711,8 @@ Two consequences, both of which have cost real projects real time:
582
711
 
583
712
  Then check **both** colour schemes, not whichever your tool defaults to.
584
713
 
714
+ **A token on one ground** is overridden on its scope, `[data-surface="brand"] { --neutral: transparent; }`, after the generated file and unlayered. One selector covers both modes, because the scope reads each mode's `--on-brand-*` value; to change a ground in one mode only, override `--on-brand-neutral` in that mode's selector instead.
715
+
585
716
  **Change a ramp step through its seed, not by overriding it.** Tailwind v4 utilities do read ramp steps through `var()` (checked against a Tailwind 4.3 compile), which is what lets the `--gamut p3` layer work. The one exception is an opacity modifier: `bg-primary-500/50` also emits the step's literal value as a fallback for browsers without `color-mix()`, and an override cannot reach that. But a hand-overridden step is a fork of the palette that the contrast search never saw and `--check` cannot detect. If you need a ramp step to change, change the seed and regenerate, or point the call sites at a token you do own.
586
717
 
587
718
  Generated files carry this contract in their own header, built from the selectors that file actually emitted.
@@ -592,6 +723,7 @@ If you find yourself hand-writing a colour beside the generated file, that is th
592
723
 
593
724
  - **Deterministic.** Same inputs and version produce byte-identical output. No randomness, clocks, or environment reads. (A grey has no meaningful hue, so `hsl` output prints it as 0 rather than float noise that differs across engines.)
594
725
  - **Displayable.** Every value is inside sRGB, so the colour in the file is the colour on the page, and contrast is measured on the colour a browser paints. With `--gamut p3`, the wide layer is inside Display P3.
726
+ - **Every ground reads.** Inside each `data-surface`, every button fill stands out from the ground at 3:1 with a label that reads on it, the input edge and focus ring reach 3:1, and muted and status text read at the text floor, or `--report` names what couldn't. A token that already worked keeps the page's value.
595
727
  - **Two test tiers.** Golden fixtures pin the bytes; structural invariants pin what a fixture cannot — chiefly that every `var(--x)` an export emits resolves to a `--x:` the same output defines. Bytes can be stable and still be incoherent CSS.
596
728
  - **One dependency**, pure JS: `culori` (colour maths). APCA contrast uses the optional `apca-w3`.
597
729
  - **ESM**, Node 18+.