Starting Storybook
http://localhost:6006.
Building Static Storybook
To build a static version of Storybook that can be deployed:storybook-static/.
Writing Stories
Stories are colocated with their components. For example,ErrorMessage.tsx has its stories in ErrorMessage.stories.tsx in the same directory.
Basic Story Structure
Component Examples
See the existing stories for reference:src/components/ErrorMessage.stories.tsx- Simple component with multiple statessrc/components/Modal.stories.tsx- Complex component with children and multiple variants
Global Styles
Storybook automatically applies the same global styles as the main app:- Color variables (
GlobalColors) - Font definitions (
GlobalFonts) - Scrollbar styles (
GlobalScrollbars)
.storybook/preview.tsx.
Handling Electron APIs
Some components depend onwindow.api for Electron IPC communication. For these components:
- Preferred: Extract the component logic to accept props instead of calling IPC directly
- Alternative: Mock the
window.apiobject in.storybook/preview.tsx
Benefits
- Isolated Development: Build components without running the full Electron app
- Visual Testing: See all component states at once
- Documentation: Stories serve as living documentation with
autodocs - Faster Iteration: Hot reload is faster than Electron rebuilds
- Accessibility: Storybook addons can check accessibility issues
Configuration
.storybook/main.ts- Main Storybook configuration.storybook/preview.tsx- Global decorators and parameterstsconfig.json- Includes.storybook/**/*.tsfor type checking
Tips
- Keep stories simple and focused on visual states
- Use Storybook’s Controls addon to make props interactive
- Add multiple stories for different states (loading, error, success, etc.)
- Use the
tags: ["autodocs"]option to generate automatic documentation