Overview
Storybook is an isolated component development environment. Develop, document, and test components in isolation before integrating them into your application.
Key Features
- Component Showcase: Display all variations of components
- Interactive Docs: Show component props, states, and actions
- Testing Integration: Run tests directly in Storybook
- Accessibility Testing: Built-in a11y audit
- Design System: Create living documentation
- Addon Ecosystem: Extend with powerful addons
Quick Start
npx storybook@latest init
Write Stories
import type { Meta, StoryObj } from '@storybook/react'
import { Button } from './Button'
const meta = {
component: Button,
tags: ['autodocs']
} satisfies Meta<typeof Button>
export default meta
type Story = StoryObj<typeof meta>
export const Primary: Story = {
args: {
label: 'Click me',
variant: 'primary'
}
}
export const Secondary: Story = {
args: {
label: 'Secondary',
variant: 'secondary'
}
}
export const Large: Story = {
args: {
label: 'Large Button',
size: 'large'
}
}
Using Controls
export const Interactive: Story = {
args: {
label: 'Interactive Button',
disabled: false,
variant: 'primary'
},
argTypes: {
variant: {
control: 'select',
options: ['primary', 'secondary', 'tertiary']
}
}
}
Storybook reduces integration bugs by catching issues at the component level.