storybook
Validation hooks and five skills that keep Storybook stories building and rendering correctly.
- CCM score
- 44 of 100
- GitHub stars
- 201
Own this plugin? Claim it
What it does
- Adds 5 skills (
storybook-story-writing,storybook-args-controls,storybook-component-documentation,storybook-play-functions,storybook-configuration) and a validation hook - Runs
npm run build-storybookin directories with a.storybookfolder to catch broken stories early - Checks CSF3 format, TypeScript story types, valid args and argTypes, and that component references exist
- Designed for projects on Storybook 7.0 or higher that need stories verified on Stop and SubagentStop events
Validation and quality enforcement for Storybook projects, ensuring stories always build and render correctly.
Add marketplace
/plugin marketplace add TheBushidoCollective/hanRun it inside Claude Code once, then install the plugin below.
Install
/plugin install storybook@hanRun it inside Claude Code after adding the marketplace.
Files
Discovered from sourceStorybook - Args and Controls
Configure interactive controls and args to make stories dynamic and explorable, allowing designers and developers to test component variations in real-time.
Key Concepts
Args
Args are inputs to components that Storybook tracks and makes interactive:
export const Primary: Story = {
args: {
label: 'Button',
primary: true,
size: 'medium',
onClick: () => alert('clicked'),
},
};
ArgTypes
ArgTypes define metadata about args, including control types and documentation:
const meta = {
component: Button,
argTypes: {
backgroundColor: {
control: 'color',
description: 'Background color of the button',
},
size: {
control: { type: 'select' },
options: ['small', 'medium', 'large'],
description: 'Size variant',
},
onClick: {
action: 'clicked',
},
},
} satisfies Meta<typeof Button>;
Control Types
Storybook provides various control types for different data types:
text- String inputnumber- Number input with validationboolean- Checkbox togglecolor- Color pickerdate- Date pickerselect- Dropdown menuradio- Radio buttonsrange- Slider with min/maxobject- JSON editorarray- Array editor
Best Practices
1. Infer Controls from TypeScript
Let Storybook auto-generate controls from TypeScript types:
interface ButtonProps {
label: string;
primary?: boolean;
size?: 'small' | 'medium' | 'large';
backgroundColor?: string;
onClick?: () => void;
}
export const Button: React.FC<ButtonProps> = ({ ... }) => { ... };
const meta = {
component: Button,
// Controls inferred from ButtonProps
} satisfies Meta<typeof Button>;
2. Customize Control Types When Needed
Override auto-inferred controls for better UX:
const meta = {
component: ColorPicker,
argTypes: {
color: {
control: 'color', // Override default text input
},
opacity: {
control: { type: 'range', min: 0, max: 1, step: 0.1 },
},
preset: {
control: 'select',
options: ['primary', 'secondary', 'success', 'warning', 'danger'],
},
},
} satisfies Meta<typeof ColorPicker>;
3. Use Actions for Event Handlers
Track event callbacks in the Actions panel:
const meta = {
component: Form,
argTypes: {
onSubmit: { action: 'submitted' },
onChange: { action: 'changed' },
onError: { action: 'error occurred' },
},
} satisfies Meta<typeof Form>;
export const Default: Story = {
args: {
onSubmit: (data) => console.log('Form data:', data),
},
};
4. Set Sensible Defaults
Provide default args at the meta level:
const meta = {
component: Slider,
args: {
min: 0,
max: 100,
step: 1,
value: 50,
},
argTypes: {
value: {
control: { type: 'range', min: 0, max: 100, step: 1 },
},
},
} satisfies Meta<typeof Slider>;
5. Document Args
Add descriptions to help users understand each arg:
const meta = {
component: Tooltip,
argTypes: {
placement: {
control: 'select',
options: ['top', 'right', 'bottom', 'left'],
description: 'Position of the tooltip relative to its trigger',
table: {
defaultValue: { summary: 'top' },
type: { summary: 'string' },
},
},
delay: {
control: { type: 'number', min: 0, max: 2000, step: 100 },
description: 'Delay in milliseconds before showing the tooltip',
},
},
} satisfies Meta<typeof Tooltip>;
Common Patterns
Enum/Union Type Controls
type ButtonVariant = 'primary' | 'secondary' | 'danger';
const meta = {
component: Button,
argTypes: {
variant: {
control: 'radio',
options: ['primary', 'secondary', 'danger'] satisfies ButtonVariant[],
},
},
} satisfies Meta<typeof Button>;
Complex Object Controls
const meta = {
component: Chart,
argTypes: {
data: {
control: 'object',
description: 'Chart data points',
},
options: {
control: 'object',
description: 'Chart configuration',
},
},
} satisfies Meta<typeof Chart>;
export const Default: Story = {
args: {
data: [
{ x: 0, y: 10 },
{ x: 1, y: 20 },
{ x: 2, y: 15 },
],
options: {
showLegend: true,
animate: true,
},
},
};
Conditional Controls
Hide irrelevant controls based on other arg values:
const meta = {
component: Input,
argTypes: {
type: {
control: 'select',
options: ['text', 'number', 'email', 'password'],
},
min: {
control: 'number',
if: { arg: 'type', eq: 'number' }, // Only show for number inputs
},
max: {
control: 'number',
if: { arg: 'type', eq: 'number' },
},
showPasswordToggle: {
control: 'boolean',
if: { arg: 'type', eq: 'password' },
},
},
} satisfies Meta<typeof Input>;
Disable Controls
Disable controls for props that shouldn't be editable:
const meta = {
component: DataTable,
argTypes: {
data: {
control: false, // Disable control (use args instead)
},
onSort: {
table: { disable: true }, // Hide from docs table
},
},
} satisfies Meta<typeof DataTable>;
Grouping Controls
Organize controls into logical categories:
const meta = {
component: Modal,
argTypes: {
// Appearance
title: {
control: 'text',
table: { category: 'Appearance' },
},
size: {
control: 'select',
options: ['small', 'medium', 'large'],
table: { category: 'Appearance' },
},
// Behavior
closeOnEscape: {
control: 'boolean',
table: { category: 'Behavior' },
},
closeOnOverlayClick: {
control: 'boolean',
table: { category: 'Behavior' },
},
// Events
onClose: {
action: 'closed',
table: { category: 'Events' },
},
},
} satisfies Meta<typeof Modal>;
Advanced Patterns
Custom Control Components
Create custom controls for specialized inputs:
import { useArgs } from '@storybook/preview-api';
const meta = {
component: GradientPicker,
argTypes: {
gradient: {
control: {
type: 'object',
},
},
},
} satisfies Meta<typeof GradientPicker>;
export const Custom: Story = {
render: (args) => {
const [{ gradient }, updateArgs] = useArgs();
return (
<GradientPicker
{...args}
gradient={gradient}
onChange={(newGradient) => updateArgs({ gradient: newGradient })}
/>
);
},
};
Dynamic ArgTypes
Generate argTypes programmatically:
const themes = ['light', 'dark', 'system'] as const;
const meta = {
component: ThemeProvider,
argTypes: {
theme: {
control: 'select',
options: themes,
mapping: Object.fromEntries(
themes.map(theme => [theme, theme])
),
},
},
} satisfies Meta<typeof ThemeProvider>;
Anti-Patterns
❌ Don't Override Args in Render
// Bad
export const Example: Story = {
render: (args) => <Button {...args} label="Hardcoded" />,
};
// Good
export const Example: Story = {
args: {
label: 'Hardcoded',
},
};
❌ Don't Use Controls for Static Data
// Bad - Large mock data in controls
export const WithData: Story = {
args: {
items: Array.from({ length: 1000 }, (_, i) => ({ id: i, ... })),
},
argTypes: {
items: { control: 'object' }, // Don't make editable
},
};
// Good - Disable control for mock data
export const WithData: Story = {
args: {
items: mockLargeDataset,
},
argTypes: {
items: { control: false },
},
};
❌ Don't Duplicate ArgTypes Across Stories
// Bad
export const Story1: Story = {
argTypes: {
size: { control: 'select', options: ['small', 'large'] },
},
};
export const Story2: Story = {
argTypes: {
size: { control: 'select', options: ['small', 'large'] },
},
};
// Good - Define at meta level
const meta = {
component: Button,
argTypes: {
size: { control: 'select', options: ['small', 'large'] },
},
} satisfies Meta<typeof Button>;
Related Skills
- storybook-story-writing: Writing well-structured stories
- storybook-component-documentation: Auto-generating docs from controls
- storybook-play-functions: Testing interactions with args
Readme
Storybook
Validation and quality enforcement for Storybook projects, ensuring stories always build and render correctly.
What This Plugin Provides
Validation Hooks
- Storybook Build Validation: Runs
npm run build-storybookto ensure all stories build successfully without errors - Story Rendering: Validates that all component stories render correctly and don't throw runtime errors
- Type Safety: Ensures TypeScript stories have proper type annotations and type-safe args
Skills
This plugin provides comprehensive Storybook expertise across five key areas:
- storybook-story-writing: Creating well-structured stories using CSF3 format, showcasing component variations, and following best practices
- storybook-args-controls: Configuring interactive controls and args for dynamic component exploration with proper type constraints
- storybook-component-documentation: Auto-generating comprehensive documentation using autodocs, MDX, and JSDoc comments
- storybook-play-functions: Writing automated interaction tests within stories to verify component behavior and user interactions
- storybook-configuration: Setting up Storybook with optimal configuration, addons, and framework-specific integrations
Installation
han plugin install storybook
Usage
Once installed, this plugin automatically validates your Storybook build:
- When you finish a conversation with Claude Code (Stop hook)
- When Claude Code agents complete their work (SubagentStop hook)
- Before commits (when combined with git hooks)
Build Validation
The plugin runs npm run build-storybook in directories containing a .storybook folder. This ensures:
- All stories are valid and can be compiled
- No TypeScript errors exist in story files
- No runtime errors occur during rendering
- All dependencies are properly imported
- Component props are correctly used
Package.json Script
Ensure your project has a build-storybook script:
{
"scripts": {
"storybook": "storybook dev -p 6006",
"build-storybook": "storybook build"
}
}
What Gets Validated
Story Files
- ✅ CSF3 format compliance
- ✅ TypeScript type safety
- ✅ Valid args and argTypes
- ✅ Proper imports and exports
- ✅ Component references exist
Configuration
- ✅ Valid
.storybook/main.tsconfiguration - ✅ Working preview configuration
- ✅ Addon compatibility
- ✅ Framework integration
Build Output
- ✅ All stories compile successfully
- ✅ No console errors during build
- ✅ Assets are properly bundled
- ✅ Static build is generated
Requirements
- Storybook 7.0 or higher (8.0+ recommended)
- Node.js 18 or higher
- npm or yarn for running build scripts
- A
.storybookdirectory in your project
Supported Frameworks
This plugin works with all Storybook-supported frameworks:
- React (Vite, Webpack, Next.js)
- Vue 3 (Vite, Webpack)
- Angular
- Web Components
- Svelte
- Solid
- Preact
Common Issues
Build Script Not Found
Error: npm ERR! missing script: build-storybook
Solution: Add the script to your package.json:
{
"scripts": {
"build-storybook": "storybook build"
}
}
TypeScript Errors in Stories
Error: Type errors in story files
Solution: Ensure proper types are imported and used:
import type { Meta, StoryObj } from '@storybook/react';
const meta = {
component: Button,
} satisfies Meta<typeof Button>;
type Story = StoryObj<typeof meta>;
Build Fails on Missing Dependencies
Error: Module not found during build
Solution: Install missing dependencies:
npm install @storybook/addon-essentials --save-dev
Customization
Override Build Command
If you use a custom build script, create a han-config.yml in your project root:
plugins:
storybook:
hooks:
storybook-build-validation:
command: "npm run custom-storybook-build"
Disable for Specific Projects
In a monorepo, disable validation for specific packages:
plugins:
storybook:
hooks:
storybook-build-validation:
enabled: false
Best Practices
Always Run Locally First
Before relying on the hook, test your build locally:
npm run build-storybook
Fix Warnings Early
Don't ignore build warnings—they often indicate real issues:
Warning: Component 'Button' is missing a display name
Keep Stories Simple
Complex logic in stories can break builds. Move complexity to components:
// ❌ Bad - Complex logic in story
export const Complex: Story = {
render: (args) => {
const [state, setState] = useState();
// Complex logic...
return <Component {...args} />;
},
};
// ✅ Good - Logic in component
export const Complex: Story = {
args: {
// Simple args only
},
};
Use TypeScript
TypeScript catches errors before build time:
// Catches type errors immediately
const meta = {
component: Button,
args: {
invalidProp: true, // TypeScript error!
},
} satisfies Meta<typeof Button>;
Details
- Marketplace
- TheBushidoCollective/han
- Source
- plugins/tools/storybook
- Category
- Tool
- Keywords
- storybook, validation, component-driven, ui-testing, quality, enforcement, stories, documentation
- Listed since
- Apr 7, 2026
More from TheBushidoCollective/han
All 340Similar to storybook
More Frontend & UI Codejutsu-storybookPluginTheBushidoCollective/han201 starsValidation and quality enforcement for Storybook projects, ensuring stories always build and render correctly.
jutsu-react-native-webPluginTheBushidoCollective/han201 starsValidation and quality enforcement for React Native Web projects with cross-platform components, styling, navigation, performance, and testing.
verificationSkillvercel/vercel-plugin315 installsVerification orchestrator that infers the user story and checks the full browser-to-data flow with evidence.
senior-frontendSkilldavila7/claude-code-templates2.2K installsFrontend skill that enforces project reuse, full UI state coverage, accessibility, and browser verification before completion.
react-native-storybookPluginstorybookjs/react-native1.3K starsCreate and edit React Native Storybook stories using Component Story Format (CSF). Includes controls reference, addon configuration, and portable story patterns
frontend-fundamentalsPlugintoss/frontend-fundamentals2K starsFrontend development best practices: code quality principles (readability, predictability, cohesion, coupling) and accessibility guidelines by Toss