Storybook — starter
StarterInit in an existing React app
bash
cd my-app
npx storybook@latest initStart:
bash
npm run storybook
# often http://localhost:6006Build static docs (host on Cloudflare Pages if you want):
bash
npm run build-storybook
# output typically storybook-static/First CSF story (React)
tsx
// Button.stories.tsx
import type { Meta, StoryObj } from '@storybook/react'
import { Button } from './Button'
const meta = {
title: 'UI/Button',
component: Button,
tags: ['autodocs'],
args: {
label: 'Click me',
},
} satisfies Meta<typeof Button>
export default meta
type Story = StoryObj<typeof meta>
export const Primary: Story = {
args: { variant: 'primary' },
}
export const Secondary: Story = {
args: { variant: 'secondary' },
}Mental model
text
Component → Story (props state) → Docs pageOne story = one meaningful UI state (loading, error, long text, mobile).