The Journal

Design Systems3 min read

Using Storybook to Build Better Design Systems

Storybook isn't just a component viewer. It's a development environment that changes how you build and maintain design systems.

Building a component inside the real app is a slog — wire up data, click four screens to reach the empty state, then squint at it buried in the rest of the UI. Storybook pulls the component onto a clean bench where every state is one click away. Its real value, though, is what a story becomes: the component’s contract.

Stories are the spec

A story is a component frozen in one exact state, written as code. List them out and you’ve specified the component: default, loading, disabled, error, long-label. If a state isn’t worth a story, ask whether it’s worth supporting.

button.stories.tsx
import type { Meta, StoryObj } from '@storybook/react';
import { Button } from './button';

const meta: Meta<typeof Button> = { component: Button };
export default meta;

type Story = StoryObj<typeof Button>;

export const Default: Story = { args: { children: 'Save' } };
export const Loading: Story = { args: { loading: true } };
export const Destructive: Story = {
  args: { variant: 'destructive', children: 'Delete' },
};

This is the flip. You’re not documenting the component after the fact — the stories are the definition of done. You build until every one of them renders right.

Test the interaction

A rendered story is only half the contract; behavior is the other half. Storybook’s play function drives the component after it mounts — click the trigger, assert the dialog opens — using that same story as the fixture.

Wire it into CI and every story doubles as an interaction test. One artifact does three jobs: spec, live demo, and regression test.

Publish per PR

The last piece is making stories visible to people who don’t run your dev server. Publish the built Storybook on every pull request, through Chromatic or a static deploy, so a reviewer opens a URL and sees the actual states.

Now designers catch a wrong hover color in review instead of production. The story you wrote to build the component becomes the thing the whole team signs off on.

Start here

Add Storybook to one component and write a story for every state it can be in. Make those stories the checklist for done.

Once that feels normal, add a play test and publish on PRs. Your components stop being things you hope work and start being things you can prove.

Frequently asked questions

What is Storybook used for in a design system?
Storybook is a development environment where you build each component on a clean bench with every state one click away. Beyond a viewer, a story is the component's contract: list out default, loading, disabled, error, and long-label stories and you've specified the component, making the stories the definition of done.
How do you test component behavior in Storybook?
Use Storybook's play function, which drives the component after it mounts, for example clicking a trigger and asserting a dialog opens, using the story itself as the fixture. Wire it into CI and every story doubles as an interaction test, so one artifact serves as spec, live demo, and regression test.
How can designers review components before they ship?
Publish the built Storybook on every pull request through Chromatic or a static deploy, so reviewers open a URL and see the actual component states. Designers then catch problems like a wrong hover color in review instead of production, and the story you wrote to build the component becomes what the team signs off on.