design · diff

git:20261116.37c9155 to git:20261116.329f8ab

32 added, 7 removed. Audit A to A.

What this update changes in the checks

No check changed: every fixed check gives the same answer before and after this update.

A tripped check is a label, not a verdict: read the matched text and the lines below. This week's updates that newly trip a check.

---
name: design
description: "Design or review anything a person looks at, built from a spec in this repository: a page, screen, component, chart, dashboard, report or CLI output. Use before writing UI code, when choosing a layout or visual direction, and when reviewing UI for clutter, wordiness or missing spec content."
---
# Design from the spec
## Before you draw
1. **Inventory.** For each story in `spec/**/*.md`, write down what the user
must see or do, and the rule behind it. That list is the whole content:
everything on it ships; no page, section, setting or sample content off it does.
2. **Cut.** For each item ask: does the user need to see this, here, now? What
do they need that is not on the list? Remove what fails; add what is missing.
3. **Three directions.** Sketch three different approaches (layout, hierarchy,
brand treatment), a sentence or a rough SVG each. Pick the one that shows the
inventory with the fewest elements and the clearest identity.
## Rules
| Instead of | Use |
|---|---|
| Text a visual can carry | A chart, icon, color, shape or SVG |
| A number inside a sentence | The number alone, large, or a bar or meter |
| A status word | Color, shape or icon, with the word as its accessible name |
| A paragraph explaining a flow | A diagram |
| A label repeating what the element shows | Nothing |
| A chip, pill, badge, eyebrow or divider | Position, weight or color, or nothing |
| Filler in empty space | Whitespace |
- **Few words.** No explanations, disclaimers, helper text, sub-headers,
taglines or detail lines under titles. One heading per view at most.
- **Accessible.** Every visual keeps its meaning in `aria-label` or `alt`. Text
contrast meets WCAG AA.
- **Untested.** Words, layout and styles get no tests. A journey test through
the UI asserts what the user can do and what the state became, not what the
page says (AGENTS.md, "Tests").
- **One system.** One type pairing, a small palette with one accent and one
spacing scale, as the project's design tokens. Extend an existing component
before adding one.
- **Tokens.** Every interface is built on the stack (AGENTS.md, "The
stack"). Name a color, size or radius by its token, never by its value; a
new value is a new token, added once ("Components, stories and tokens").
## Review: two or three passes
Reread the rules above before each pass, then ask:
- What could go with no story losing anything? Remove it.
- What text could be a visual? What visual could be smaller?
- What from the inventory is missing?
- Does the eye land first on what matters most?
Stop when a pass changes nothing. Report the chosen direction in one line, and
anything cut that the user might expect to see.
## Components, stories and tokens
A component is ordinary source the project owns: one `.tsx` file in
`src/components/`, a named export, an exported `<Name>Props` type, and a
JSDoc sentence on the component and on each prop that needs one. In this
repository they are `@repo/ui`; a standalone project keeps its own.
| | Source, kept in Git | Generated, never committed | Command, in the project |
|---|---|---|---|
| Tokens | `tokens.json`, and `design.md` describing them | `generated/tokens.css`, `generated/theme.css` (the Tailwind v4 entry) | `spec tokens build`, `check` |
| Stories | the component, and `<Name>.meta.tsx` where its types are not enough | `generated/stories/`: Storybook stories, `catalog.json`, and a mount test and a browser test (accessibility) of every story; a disabled or loading story is played to check that it refuses clicks and keys | `spec stories gen [--watch] [--check]` |
`spec` is the tool's command: `pnpm exec spec` in a project that installed
it, `node ../../spec.ts` in an example. In `@repo/ui`: `pnpm gen` (the stories),
`pnpm storybook`, `pnpm test`, `pnpm test:browser`; in
`@repo/design-system`: `pnpm build`, `pnpm check`.
- **Never write a story for what the generator can derive.** It reads each
prop's type, default and JSDoc and writes a Default story, one per option
of a union or boolean prop, and Disabled, Loading, Error and Empty where
such a prop exists, twelve at most. A hand-written `<Name>.stories.tsx`
beside the component is kept, and wins over a generated story of the same
name.
- **`<Name>.meta.tsx`** exports `meta: ComponentMeta<Props>` (from
`vibestack/stories`): `args` every story starts from, named `examples` and
`states`, `bounds` of a numeric prop, a `schema` to sample, a `decorator`,
and `play` interactions, which is where a component's behaviour is tested:
no test compares screenshots. Stories, tests and Studio read the same
object; a field it does not have is reported. A required prop the generator cannot give a
value is reported, with the field to add; it never invents data.
- **A component that shows a model** says so: `@model spec/index.md` in its
JSDoc links it to that spec's state and events, and `@design design.md#…`
to its design document. Studio's Components view follows both ways. The spec
must have state (its generated module exports `initial`); a tag on a stateless
dispatcher is reported, so name the spec whose model holds what it shows.
- **A file named after one of its exports** (`Dialog.tsx`) gives stories to
that component; its other exports are its parts.
- - **Colors, radii, shadows and fonts are tokens.** A color may not share a
- text size's name, since `text-<name>` would set only the color. Use the utilities named
- after them (`bg-primary`, `text-muted-foreground`, `rounded-md`); the lint
- rules of `vibestack/design/eslint.ts` refuse a palette class (`white` and
- `black` too), an arbitrary or named color, a radius, shadow or font the
- tokens do not define, and a literal or named color in a style. Merge classes with `cn()`; use CVA
+ - **What `tokens.json` holds.** Each group becomes the Tailwind v4 theme
+ variables, and so the utilities, shown; all but `color`, `radius` and
+ `font.sans`/`font.mono` are optional, and `*` is a name the project chooses.
+
+ | Path | Value | Utility |
+ |---|---|---|
+ | `color.light.*`, `color.dark.*` | opaque `oklch(L C H)`; the 22 required roles (shadcn's, `ok`, `warn`, `info`) and any palette color, named in `light`; one `dark` leaves out keeps its light value | `bg-*`, `text-*`, `border-*` … |
+ | `radius`; `rounded.*` | rem or px | `rounded-sm` … `rounded-xl` derived from `radius`; `rounded-*` |
+ | `font.*` | a font stack | `font-*` |
+ | `text.*` | rem or px, or `{ size, leading?, tracking? }` to set its line height and letter spacing too | `text-*` |
+ | `weight.*` | 1 to 1000 | `font-*` |
+ | `leading.*`, `tracking.*` | a number or rem/px; em | `leading-*`, `tracking-*` |
+ | `z.*` | an integer | `z-*` |
+ | `focus.width`, `focus.offset` | rem or px, 2px unless given | the `:focus-visible` ring; `outline-focus` only when `focus.width` is declared, `outline-offset-focus` only when `focus.offset` is |
+ | `shadow.*`, `blur.*`, `gradient.*`, `animate.*` with `keyframes.*`, `motion.duration.*`, `motion.ease.*`, `breakpoint.*` | CSS values | `shadow-*`, `blur-*`, `bg-gradient-*`, `animate-*`, `duration-*`, `ease-*`, `sm:` … |
+
+ A scale's names (`text`, `weight`, `leading`, `tracking`, `z`) may start
+ with a digit (`2xl`, `10`); a color's may not. A name Tailwind already gives
+ another meaning in the same classes is refused (a color `sm` would also be
+ `text-sm` and `shadow-sm`; a weight `mono` would be `font-mono`), as is one
+ name in two groups that share a utility: a color and a text size or shadow,
+ a font and a weight.
+ - **Colors, radii, shadows, fonts and type are tokens.** Use the utilities
+ named after them (`bg-primary`, `text-muted-foreground`, `rounded-md`); the
+ lint rules of `vibestack/design/eslint.ts` refuse a palette class (`white`
+ and `black` too), an arbitrary or named color, a radius, shadow or font the
+ tokens do not define, and a literal or named color in a style. Once
+ `tokens.json` declares a non-empty `text`, `weight`, `leading`, `tracking`
+ or `z`, they also refuse an arbitrary value and Tailwind's own names in
+ that group (`text-sm`, `font-bold`, `leading-none`, `leading-6`, `z-50`),
+ never a name the project declared. Merge classes with `cn()`; use CVA
only where a component has real variants.
- **A design change is a token change.** Describe it in `design.md`, write
it as `[{ "path": "color.light.primary", "value": "oklch(…)", "reason": "…" }]`,
and run `spec tokens apply changes.json`: it refuses an
unknown path, an invalid value and a contrast below WCAG AA (4.5:1 for
- text, 3:1 for the edge of a control, `input`), and prints
+ text, 3:1 for the edge of a control, `input`, and the focus `ring`), and prints
the diff; `--write` applies it and rebuilds the CSS. Prose is never read
as tokens.
To change a component: find it in `generated/stories/catalog.json` or in
Studio's Components view, read its props and model there, edit the source,
run `pnpm gen` (or leave `pnpm storybook` running), look at it, then
`pnpm test` and `pnpm lint`.