storybook-workshop
A story is not a demo. It is the component's executable documentation: the artefact an
agent reads to learn what the component accepts, and the harness that catches a contrast or
focus defect while the component is still in isolation. Stack-agnostic — the tool is
Storybook, the discipline is not.
Lifted out of react-shadcn-ui § Component workshop, which
keeps a pointer here rather than a copy.
The Iron Law
ONE CONCEPT PER STORY. NEVER A "SizesAndVariants" STORY.
EVERY COMPONENT EXPORT AND EVERY STORY CARRIES A JSDoc @summary.
A STORY THAT SHOWS AN ANTI-PATTERN IS TAGGED `!manifest` OR THE AGENT LEARNS FROM IT.
STORIES RUN. A STORY NOBODY RUNS IS A SCREENSHOT WITH EXTRA STEPS.
When to use
A shared component library exists or is being started, and one of: stories are being added,
an agent needs an inventory of what the library already offers, an a11y regression should be
caught in isolation rather than on a screen, or a Storybook MCP channel is available and
nobody has decided whether to use it.
Skip it for a handful of one-off components with a single consumer — the setup and
upkeep outweigh the return, and that judgement belongs to the reader rather than to this
skill.
The story set — one concept per story
The state-coverage rows every reusable component owes become story names:
Default, Loading, Empty, Error, Disabled, Dark. One concept each.
A combined story — the canonical anti-pattern is SizesAndVariants — fails at both jobs it
has: a human cannot tell which knob caused what, and an agent reading it cannot learn a
single prop's effect because every value is co-present. Split it, one axis per story
(Storybook's own guidance on writing effective stories).
Stories render under the same semantic tokens as the app and the .dark class; a
hardcoded preview theme makes the workshop lie about what the component looks like in place.
The five behavioral stories — assert a value, never an image
Hover, Focus, Active, Keyboard and ReducedMotion join the set above, and they
carry one extra rule: **each asserts a resolved computed style or a handler effect, never a
screenshot.** A component that owes a state checklist and proves it with a pixel diff has
not proved it — a screenshot is a resting frame, and none of these five is a resting frame.
| Story | Drive | Assert |
|---|---|---|
| Hover | userEvent.hover(el) | the resolved property the hover rule is supposed to change actually changed |
| Focus | focus the element | the :focus styles resolve as intended |
| Keyboard | userEvent.tab() until the element is active | a visible :focus-visible indicator resolves — programmatic focus does not set it in Chromium, so a .focus() call reports a real focus ring as absent |
| Active | press and hold | what pressing adds on top of hover — a pointer cannot press without hovering, so asserting against the resting style makes one removed hover rule fail two stories |
| ReducedMotion | emulate prefers-reduced-motion: reduce | what the surface presents instead of the motion, per