Storybook
Storybook is a workshop for building UI components in isolation — outside your running app, outside its routes and data-fetching and auth. You write stories (each a component in a specific state), and Storybook renders them in a browsable sandbox where you can develop, document, and test every component and every variant on its own.
It's the backbone of component-driven development and the standard tool for design systems: a place where the button, the modal, and the date-picker exist independently of any page, in every state (loading, error, empty, disabled), as living documentation designers and developers share. Most serious component libraries — from company design systems to open-source kits — ship a Storybook.
TL;DR
- A story is one component in one state —
Primary,Loading,WithError— rendered in isolation, no app required. - Develop components outside the app: no clicking through five screens and seeding data to reach the error state; render it directly.
- Storybook is framework-agnostic (React, Vue, Svelte, Angular, web components, Solid).
- Stories double as test cases and documentation: the same story feeds visual regression, interaction tests, accessibility checks, and auto-generated docs.
- Args and controls turn stories into interactive playgrounds — tweak props live in the UI.
- Its highest value is design systems and shared component libraries; for a tiny app with few components, it can be more setup than it's worth.
Quick Example
Stories for a Button component (Component Story Format, the standard):
Every state is now a click away, developed without touching the app — and the Loading, Danger, and Disabled edge cases you'd otherwise struggle to reproduce are permanently reachable.
Core Concepts
Stories and Component-Driven Development
The workflow inverts the usual order: build the component bottom-up in isolation, prove every state, then wire it into pages. This is component-driven development, and it changes how UI gets built:
- You develop the empty/loading/error states as first-class artifacts, not afterthoughts you hit by accident in QA.
- Components stay decoupled — if it renders in Storybook with just props, it has no hidden dependencies on app context.
- Designers, PMs, and developers review real rendered components, not mockups or a half-built page.
Args and Controls
Stories are parameterized by args (props); Storybook auto-generates a controls panel to edit them live:
Non-developers can toggle every prop combination in the browser — the component becomes an interactive spec. Args also compose: define a base, override per story.
Stories as Tests
The payoff that justifies the setup: one story feeds many kinds of testing.
Because the test is a story, it's also visible, browsable documentation — the artifact serves three purposes at once. Storybook's test runner (Vitest-based) executes these in CI.
Design Systems: The Killer Use Case
For a design system or shared component library, Storybook becomes the published, living catalog: every component, every variant, interactive controls, usage docs, and design tokens, deployed as a static site the whole org browses. It's simultaneously the development environment, the documentation, the test suite, and the design-dev contract. This is where Storybook stops being "nice tooling" and becomes core infrastructure — see Web Components for the framework-agnostic design-system angle.
Common Mistakes
Stories Only for the Happy Path
A single Default story per component wastes the tool. The value is in the states that are painful to reach in the app — loading, empty, error, long-content, RTL, disabled. Those edge-case stories are where bugs hide and where Storybook earns its keep.
Components That Need the Whole App to Render
If a component only works with a live router, auth context, and API, it won't render in isolation — which is a design smell, not a Storybook limitation. Use decorators to provide context (mock providers, router), and treat "hard to put in Storybook" as a signal the component is over-coupled.
Treating It as Docs-Only
Rendering components but never adding play functions, visual regression, or a11y checks leaves most of the value on the table. Stories you already wrote for development are free test cases — wire them into CI.
Storybook Drift
A Storybook that isn't run in CI rots: stories break, visual snapshots go stale, nobody trusts it. Run the test runner and (ideally) visual regression on every PR so the catalog stays honest.
Over-Adopting for Tiny Apps
For an app with a handful of components tightly bound to pages, Storybook's setup and maintenance can exceed its benefit. It shines with reusable components and shared libraries — match the tool to that reality.
FAQ
Storybook or just testing in the app?
Different scopes. In-app testing verifies flows and integration; Storybook isolates components — developing and testing them without the app's data, routes, and state getting in the way. Most mature frontends use both: Storybook for component-level work, Playwright/Cypress for end-to-end.
Does it work with my framework?
Almost certainly — Storybook supports React, Vue, Svelte, Angular, Solid, Web Components, and more, and integrates with Vite/Next.js/etc. builders. The stories API (CSF) is largely consistent across frameworks.
Is it worth it for a solo dev or small team?
If you're building reusable components or a design system — yes, even solo, because the isolated development loop and permanent edge-case catalog pay off immediately. For a small app of page-specific one-off components, it's likely overkill.
How does visual regression testing work?
Each story is rendered and captured as an image; on later runs, new captures are diffed against the baselines and any pixel changes are flagged for human review (accept as intended, or fix). Chromatic (from Storybook's makers) is the managed option; Storybook + Playwright is the self-hosted route. It catches the "we didn't mean to change that" visual bugs unit tests never see.
Storybook vs a component playground like a live docs site?
Storybook is that playground, plus development environment, plus test harness. Tools like Docusaurus or a custom MDX site can document components, but Storybook uniquely unifies build/document/test around the same story artifacts.
Related Topics
- React / Vue / Svelte — Frameworks Storybook supports
- Web Components — Framework-agnostic design systems
- Accessibility — Per-component a11y checks via the addon
- Integration Testing — Where interaction tests fit
- Playwright — Pairs with Storybook for visual/E2E testing
- CI/CD — Running the test runner on every PR
- Responsive Design — Testing components across viewports