---
name: storybook
description: Storybook 8+ — writing stories (CSF3), configuring main.ts / preview.ts, addons (essentials, a11y, designs, MSW), parameters, args/argTypes, decorators, doc blocks, test-runner / Vitest integration, and framework setup (React/Vite, Next.js, SvelteKit, Vue). Use when authoring or debugging stories, configuring Storybook, mocking network requests, or wiring component tests.
---
# Storybook
Storybook is a workshop for building, documenting, and testing UI components in isolation. This skill covers CSF3 story syntax, configuration entry points, addons, mocking, and the test-runner.
## When to use
- Authoring or refactoring `*.stories.ts(x)` files
- Editing `.storybook/main.ts` or `.storybook/preview.ts`
- Adding/removing addons (a11y, designs, MSW, Vitest)
- Setting up Storybook for a new framework (React/Vite, Next.js, SvelteKit, Vue)
- Mocking network requests or modules in stories
- Wiring up the test-runner or Vitest project
## Key concepts
- **CSF3 (Component Story Format 3)** — default export is `Meta`, named exports are `StoryObj`. `args` drive props; `argTypes` describe controls.
- **`main.ts`** — declares `stories` glob, `framework`, `addons`, and Vite/Webpack tweaks.
- **`preview.ts`** — global `parameters`, `decorators`, `loaders`, `globalTypes` (theme/locale toggles).
- **Decorators** — wrap stories with providers (Theme, Router, Query). Stack global → component → story.
- **Loaders** — async setup that runs before render (e.g. MSW init, fetch fixtures).
- **Doc blocks** — ``, ``, `