Generate and configure Storybook 9 for any framework with automatic detection, SOTA best practices, and platform-specific optimizations (Web, Tauri, Electron)
/plugin marketplace add flight505/storybook-assistant-plugin/plugin install flight505-storybook-assistant@flight505/storybook-assistant-pluginThis skill is limited to using the following tools:
This skill generates production-ready Storybook 9 configurations with:
This skill should be used when:
# Detect project framework and configuration
bash ${CLAUDE_PLUGIN_ROOT}/scripts/detect-framework.sh
# Use skill to generate configuration
# The skill will use AskUserQuestion for user preferences
| Framework | Storybook Package | Minimum Version | Bundler |
|---|---|---|---|
| React | @storybook/react-vite | 18.0.0 | Vite (preferred), Webpack |
| Vue | @storybook/vue3-vite | 3.0.0 | Vite (preferred), Webpack |
| Svelte | @storybook/svelte-vite | 5.0.0 | Vite |
| Angular | @storybook/angular | 18.0.0 | Webpack |
| Next.js | @storybook/nextjs-vite | 14.0.0 | Vite |
| Solid.js | @storybook/solid-vite | 1.8.0 | Vite |
| Lit | @storybook/web-components-vite | 3.0.0 | Vite |
1. Vitest Integration for Testing
// main.ts - Enable Vitest addon
addons: [
'@storybook/addon-vitest', // Real browser testing
]
2. Accessibility Testing
// preview.ts - Configure axe-core
parameters: {
a11y: {
config: {
rules: [
{ id: 'color-contrast', enabled: true },
{ id: 'button-name', enabled: true },
],
},
},
}
3. Autodocs with Tags
// main.ts - Auto-generate documentation
docs: {
autodocs: 'tag', // Stories with 'autodocs' tag get automatic docs
}
// story.tsx
export default {
tags: ['autodocs'], // Enable automatic documentation
}
4. Performance Optimization
// main.ts - Vite optimization
viteFinal: async (config) => {
return {
...config,
optimizeDeps: {
include: ['@storybook/blocks'],
},
};
}
// Build optimization for CI
build: {
test: {
disabledAddons: ['@storybook/addon-docs'], // 2-4x faster
},
}
5. Modern Controls
// preview.ts - Enhanced controls
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/i,
},
expanded: true, // Show all controls by default
}
Standard configuration with all features:
Additional configuration:
// preview.ts - Tauri IPC mocks
decorators: [
(Story) => {
if (typeof window !== 'undefined' && !window.__TAURI__) {
window.__TAURI__ = tauriMocks;
}
return Story();
},
]
Best Practices:
window.__TAURI__ APIs in storiesWebpack overrides required:
// main.ts - Electron configuration
webpackFinal: async (config) => {
config.target = 'web'; // Override electron-renderer
config.externals = {}; // Clear Electron externals
config.resolve.alias = {
electron: false, // Mock electron module
};
return config;
}
// preview.ts - Electron preload API mocks
decorators: [
(Story) => {
if (typeof window !== 'undefined' && !window.api) {
window.api = electronMocks;
}
return Story();
},
]
Limitations:
electron imports need refactoringThe skill detects and integrates with:
// preview.ts
import { ThemeProvider, createTheme } from '@mui/material/styles';
import CssBaseline from '@mui/material/CssBaseline';
const theme = createTheme({
palette: {
mode: 'light',
},
});
export const decorators = [
(Story) => (
<ThemeProvider theme={theme}>
<CssBaseline />
<Story />
</ThemeProvider>
),
];
// Install dependencies
npm install --save-dev @testing-library/react @testing-library/user-event
// Enable addon
npx storybook@latest add @storybook/addon-vitest
// Install addon
npx storybook@latest add @storybook/addon-a11y
// Configure in preview.ts
parameters: {
a11y: {
element: '#storybook-root',
config: {
rules: [
{ id: 'color-contrast', enabled: true },
],
},
},
}
// Install V8 coverage
npm install --save-dev @vitest/coverage-v8
// Run with coverage
npm run storybook:coverage
// .storybook/main.ts
import type { StorybookConfig } from '@storybook/react-vite';
const config: StorybookConfig = {
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
addons: [
'@storybook/addon-essentials',
'@storybook/addon-vitest',
'@storybook/addon-a11y',
'@storybook/addon-links',
],
framework: {
name: '@storybook/react-vite',
options: {
strictMode: true,
},
},
docs: {
autodocs: 'tag',
},
viteFinal: async (config) => {
return {
...config,
optimizeDeps: {
include: ['@storybook/blocks'],
},
};
},
};
export default config;
// .storybook/preview.ts
import type { Preview } from '@storybook/react-vite';
import '../src/index.css'; // Global styles
const preview: Preview = {
parameters: {
actions: { argTypesRegex: '^on[A-Z].*' },
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/i,
},
expanded: true,
},
layout: 'centered',
a11y: {
config: {
rules: [
{ id: 'color-contrast', enabled: true },
],
},
},
backgrounds: {
default: 'light',
values: [
{ name: 'light', value: '#ffffff' },
{ name: 'dark', value: '#1a1a1a' },
],
},
},
globalTypes: {
theme: {
description: 'Global theme for components',
defaultValue: 'light',
toolbar: {
title: 'Theme',
icon: 'circlehollow',
items: ['light', 'dark'],
dynamicTitle: true,
},
},
},
};
export default preview;
Before completing configuration: