Storybook authoring guide
Stories are the component playground. A control must be a real, valid knob: it changes the canvas, it cannot produce an invalid state, and its options come from the component rather than a copy of them.
Controls are declared per story file in argTypes. There is no global guessing: the only global matcher is date, and the color matcher is off so token props named color stay selects. The theme toolbar lives in .storybook/preview.ts; do not re-implement it per story.
Control taxonomy
| The prop is | Control | Example |
|---|---|---|
| A small union or token set (up to about 4) | inline-radio with options | Button variant, size; Surface variant |
| A longer union or token set | select with options | Button color; Surface radius; Text tag |
| An optional union | select, with undefined first | Text as, GlassText underline |
| A boolean flag | boolean | Chip dot, Button loading |
| A bounded number (duration, size, count, intensity) | { type: "range", min, max, step } | Meter value, DrawLine delayMs, Icon size |
| User-facing copy | text | Button text, Chip children |
| A design-token color | select of the token names | Button color |
| A freeform color (rare) | color, set explicitly | Only where the prop accepts any CSS color |
| A structured value (an array or object of plain data) | object | ExperienceMemories memories |
| A callback | action (or fn() in args) | Button onClick, ErrorPage reset |
| A React node, ref, class name, style, internal state | control: false | children that is markup, className, icon |
| A value that breaks the story when edited | control: false plus a description | SkillIcon skill |
Rules
- Options come from the component. Derive them from the object the component reads (
Object.keys(buttonVariantStyles),Object.keys(variantClass),textTagOptions) or type them withsatisfies readonly Prop[], so a removed value failspnpm type-checkinstead of drifting silently. Do not write a literal list that restates a union with no check. Shared option sets sit next to the component and leave through its barrel (textTagOptionsfrom@/components/Text). - Every exposed control has a
descriptionwhen its name does not already say what it does: the constraint, the valid range, or the effect. These render in the autodocs table. - Hide what does not help. Anything that is not a knob (
className,style, ref, markupchildren, test ids, internal flags) getscontrol: false, so the panel lists only what changes the canvas. A prop a scenario pins goes in that story’sargsand is disabled withargTypes: { prop: { control: false } }on the story. - Controls must change the canvas. If a prop only matters once (a one-time reveal, an animation on mount), render the story with a
keybuilt from the inputs so editing a control remounts it. SeeSheenTitle. - Defaults are meaningful. Put a realistic value in meta
args. Use real copy shapes, not “Lorem ipsum” or “test”. Content stays inside the rules indocs-site/content/content-model.mdx: sample copy is labelled as a sample and never invents biography. - One Playground per component. Name the story that follows the controls
Playground, and keep scenario stories (Sizes,States,Empty) for cases a single control cannot show. Do not add near-duplicate stories for every value. - Callbacks use
fn(). Putfn()inargssoplaycan assert on it and the Actions panel logs it. - Keep
playfunctions and the Vitest browser run green. A control change must not alter what aplayfunction asserts at its default args. - Stateful components get a wrapper. If the component needs context or state to react (a cursor provider, a selected tab), write a small wrapper in the story that supplies it, so controls and interaction both work. See
FloatingNavandGlassText. - Theme, reduced motion and width are toolbar and browser concerns. Use the Theme toolbar for light and dark. For reduced motion, toggle it in the browser’s rendering settings. For width, use Storybook’s viewport tool. Add a dedicated story only where the layout changes in a way the tools cannot show.
- Titles start with Foundations, Components, Containers, Partials or Sections. Design explorations are the one exception: they live in
src/prototypes/and usePrototypes(see below).
Checklist for a new or changed story
-
tags: ["autodocs"]and a one-line component description (a JSDoc on the component or a story comment). - Every union, token and boolean prop has an explicit control with options from the component.
- Every non-knob prop has
control: false. - Constrained numbers use
rangewithmin,maxandstep. - Callbacks are
fn()oraction. - Changing each control visibly changes the canvas (remount with a
keywhere needed). -
pnpm type-check,pnpm lint,pnpm format:checkandpnpm testpass.
Audit of existing stories
Status after the controls pass. “Explicit” means every constrained prop has an argTypes entry with options from the component; “Inferred” means Storybook’s own inference is already correct for the props the component has.
| Story | Props exposed | Control state |
|---|---|---|
| Button | variant, size, color, subset, loading, disabled, href | Explicit. Options from buttonVariantStyles and buttonSizeVariants; onClick is an action. |
| Text | tag, as, text | Explicit. Options from textTagOptions and textElementOptions. |
| Surface | variant, radius, lift, children | Explicit. Options from variantClass and radiusClass. |
| Eyebrow | variant, as, children | Explicit. variant from labelTypeSizes. |
| SkillIcon | size, skill | Explicit. size from tileSize; skill is fixed. |
| SheenTitle | text, tag, as, delayMs | Explicit. Remounts on change so the sweep replays. |
| Chip, Meter, Icon, FocusReveal, DrawLine, VisuallyHidden | enums, booleans, ranges, text | Explicit already; descriptions added for Chip and Meter. |
| GlassText, ContentContainer, SectionHeader, DescriptionList | enums, booleans, ranges | Explicit already. |
| ErrorPage | error, reset | error hidden, reset is an action. |
| ExperienceMemories | memories | object control over plain data. |
| Container, GradientMaskHover, LuminanceTextWrapper | children, className | Hidden: markup and class names are not knobs. |
Glass, FloatingNav, ThemeToggle, Clock, LogoMark, Footer, the About and Landing sections, PageShell, ResumeDownload, HeaderLogoLink, helpers under config/ | none, or data from src/content | No constrained props to expose; scenarios are separate stories with play coverage. |
Prototype stories
Prototypes/ groups design explorations that are compared in Storybook and are not part of the app. A prototype lives in its own folder under src/prototypes/<name>/, uses Prototypes/<Name>/... titles, and carries a README.md saying what it explored, how to run it and what was decided. Nothing in the app may import from src/prototypes/ (ESLint enforces it); a prototype may import tokens and primitives from the app. When a direction is chosen, the real version is built in its proper layer, and the prototype stays as the record of the options. Delete a prototype when it no longer helps. The usual story rules still apply to its stories. pnpm test and CI do not run a prototype’s stories or unit tests, so a flaky or broken prototype cannot turn CI red; TEST_PROTOTYPES=true pnpm test runs them when you are working on one. Lint and type-check still cover the folder.
The first one is Prototypes/AssistantRedesign: five variants of the AI assistant panel, with controls for 23 states.
Foundations stories
Foundations/ is the visual handbook for the design tokens: Overview, Hyperfluid Responsiveness, Spacing, Layout, Radius,
Typography, Color, Fixed colors, Surfaces, Stacking, Motion, Focus ring, Accessibility and Composition, plus the small
helper pages (Rise, Visually hidden, Heading gradient, Label type, Photo rest and Period). They live in
src/config/styles/foundations/, a page with several files in its own folder (hyperfluid/, stacking/,
accessibility/, fixedColors/), or beside the token they document (themes/borderRadius.stories.tsx, helpers/*/, and
config/localization/formatPeriod/ for Period).
- Read tokens, never copy them. Layout and type tokens are plain data in
src/config/styles/themes/tokens.ts(theme.css.tsconsumes them); palettes, radius and motion are plain too. A.css.tsthat also exports class-name functions (theme.css.ts,focusRing.ts) cannot be imported at run time, so move the plain data out rather than retyping it. - An
.mdxpage imports with relative paths. The@/alias resolves in stories but not in.mdx, where it fails with “Failed to resolve import”.hyperfluid/Hyperfluid.mdxis the model for an MDX page with live demos (<Canvas of={...}>). - A new token goes in its source file, then gets a row or story on the matching page. A new topic gets its own story file
and a row in
Overview.mdx. - Each page states intent, the token or value, real usage, responsive behavior and the accessibility constraint, and its controls follow the rules above (token names as selects, no free-text token controls).
- Shared demo styles and the contrast helper sit in
foundations/demo/.