Skip to Content
ReferenceStorybook authoring guide

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 isControlExample
A small union or token set (up to about 4)inline-radio with optionsButton variant, size; Surface variant
A longer union or token setselect with optionsButton color; Surface radius; Text tag
An optional unionselect, with undefined firstText as, GlassText underline
A boolean flagbooleanChip dot, Button loading
A bounded number (duration, size, count, intensity){ type: "range", min, max, step }Meter value, DrawLine delayMs, Icon size
User-facing copytextButton text, Chip children
A design-token colorselect of the token namesButton color
A freeform color (rare)color, set explicitlyOnly where the prop accepts any CSS color
A structured value (an array or object of plain data)objectExperienceMemories memories
A callbackaction (or fn() in args)Button onClick, ErrorPage reset
A React node, ref, class name, style, internal statecontrol: falsechildren that is markup, className, icon
A value that breaks the story when editedcontrol: false plus a descriptionSkillIcon skill

Rules

  1. Options come from the component. Derive them from the object the component reads (Object.keys(buttonVariantStyles), Object.keys(variantClass), textTagOptions) or type them with satisfies readonly Prop[], so a removed value fails pnpm type-check instead 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 (textTagOptions from @/components/Text).
  2. Every exposed control has a description when its name does not already say what it does: the constraint, the valid range, or the effect. These render in the autodocs table.
  3. Hide what does not help. Anything that is not a knob (className, style, ref, markup children, test ids, internal flags) gets control: false, so the panel lists only what changes the canvas. A prop a scenario pins goes in that story’s args and is disabled with argTypes: { prop: { control: false } } on the story.
  4. Controls must change the canvas. If a prop only matters once (a one-time reveal, an animation on mount), render the story with a key built from the inputs so editing a control remounts it. See SheenTitle.
  5. Defaults are meaningful. Put a realistic value in meta args. Use real copy shapes, not “Lorem ipsum” or “test”. Content stays inside the rules in docs-site/content/content-model.mdx: sample copy is labelled as a sample and never invents biography.
  6. 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.
  7. Callbacks use fn(). Put fn() in args so play can assert on it and the Actions panel logs it.
  8. Keep play functions and the Vitest browser run green. A control change must not alter what a play function asserts at its default args.
  9. 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 FloatingNav and GlassText.
  10. 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.
  11. Titles start with Foundations, Components, Containers, Partials or Sections. Design explorations are the one exception: they live in src/prototypes/ and use Prototypes (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 range with min, max and step.
  • Callbacks are fn() or action.
  • Changing each control visibly changes the canvas (remount with a key where needed).
  • pnpm type-check, pnpm lint, pnpm format:check and pnpm test pass.

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.

StoryProps exposedControl state
Buttonvariant, size, color, subset, loading, disabled, hrefExplicit. Options from buttonVariantStyles and buttonSizeVariants; onClick is an action.
Texttag, as, textExplicit. Options from textTagOptions and textElementOptions.
Surfacevariant, radius, lift, childrenExplicit. Options from variantClass and radiusClass.
Eyebrowvariant, as, childrenExplicit. variant from labelTypeSizes.
SkillIconsize, skillExplicit. size from tileSize; skill is fixed.
SheenTitletext, tag, as, delayMsExplicit. Remounts on change so the sweep replays.
Chip, Meter, Icon, FocusReveal, DrawLine, VisuallyHiddenenums, booleans, ranges, textExplicit already; descriptions added for Chip and Meter.
GlassText, ContentContainer, SectionHeader, DescriptionListenums, booleans, rangesExplicit already.
ErrorPageerror, reseterror hidden, reset is an action.
ExperienceMemoriesmemoriesobject control over plain data.
Container, GradientMaskHover, LuminanceTextWrapperchildren, classNameHidden: 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/contentNo 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.ts consumes them); palettes, radius and motion are plain too. A .css.ts that 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 .mdx page imports with relative paths. The @/ alias resolves in stories but not in .mdx, where it fails with “Failed to resolve import”. hyperfluid/Hyperfluid.mdx is 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/.