Set up Storybook with stories for components
✓Works with OpenClaudeYou are a frontend developer setting up Storybook to document and test React components with interactive stories.
What to check first
- Run
npm list react react-domto verify React is installed (Storybook 7+ requires React 16.8+) - Check your
package.jsonto see if Storybook is already listed as a dependency - Verify your project structure has a
/srcdirectory with at least one component to document
Steps
- Install Storybook using the CLI:
npx storybook@latest init— this auto-detects your project type and installs required packages - Review the generated
.storybook/main.jsconfiguration file and update thestoriesarray to point to your component files (e.g.,'../src/**/*.stories.{js,jsx,ts,tsx}') - Create your first story file next to a component: name it
Button.stories.jsxand use the Component Story Format (CSF) with named exports - Inside the story file, export a
defaultobject withcomponent,title, andargTypesproperties to define metadata - Export individual story functions (e.g.,
export const Primary = (args) => <Button {...args} />) that acceptargsfor interactive controls - Add
argsto each story export to set default prop values that appear in the Storybook UI - Run
npm run storybook(oryarn storybook) to start the dev server onhttp://localhost:6006 - Install
@storybook/addon-essentialsif not included, then add it to theaddonsarray in.storybook/main.jsfor built-in controls, docs, and actions panels
Code
// src/Button.stories.jsx
import { Button } from './Button';
export default {
component: Button,
title: 'Components/Button',
argTypes: {
variant: {
control: 'select',
options: ['primary', 'secondary', 'danger'],
description: 'Button style variant',
},
size: {
control: 'select',
options: ['small', 'medium', 'large'],
},
onClick: {
action: 'clicked',
description: 'Callback when button is clicked',
},
disabled: {
control: 'boolean',
},
children: {
control: 'text',
},
},
tags: ['autodocs'],
};
export const Primary = {
args: {
variant: 'primary',
size: 'medium',
children: 'Primary Button',
disabled: false,
},
};
export const Secondary = {
args: {
variant: 'secondary',
size: 'medium',
children: 'Secondary Button',
disabled: false,
},
};
export const Danger = {
Note: this example was truncated in the source. See the GitHub repo for the latest full version.
Common Pitfalls
- Treating this skill as a one-shot solution — most workflows need iteration and verification
- Skipping the verification steps — you don't know it worked until you measure
- Applying this skill without understanding the underlying problem — read the related docs first
When NOT to Use This Skill
- When a simpler manual approach would take less than 10 minutes
- On critical production systems without testing in staging first
- When you don't have permission or authorization to make these changes
How to Verify It Worked
- Run the verification steps documented above
- Compare the output against your expected baseline
- Check logs for any warnings or errors — silent failures are the worst kind
Production Considerations
- Test in staging before deploying to production
- Have a rollback plan — every change should be reversible
- Monitor the affected systems for at least 24 hours after the change
Related Frontend Skills
Other Claude Code skills in the same category — free to download.
Component Generator
Generate React/Vue/Svelte components with props
Responsive Layout
Create responsive layouts with Tailwind/CSS Grid
Form Builder
Build forms with validation (React Hook Form, Formik)
State Management Setup
Set up state management (Zustand, Redux, Jotai)
Animation Creator
Create animations with Framer Motion or CSS
Dark Mode Setup
Implement dark/light mode toggle
Lazy Loading
Add lazy loading for images and components
SEO Optimizer
Add SEO meta tags, structured data, sitemap
Want a Frontend skill personalized to YOUR project?
This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.