@node-core/ui-components. Every component in that package should have a corresponding story file.
Storybook covers
@node-core/ui-components only. Components in apps/site/components do not have story files.Running Storybook
http://localhost:6006.
Story file location
Story files live alongside the component they document:Writing stories
A complete story file for theButton component:
Story anatomy
Imports
Imports
Import
Meta and StoryObj from @storybook/react, then import the component from its full package path.Type aliases
Type aliases
Create
Story and Meta type aliases bound to the component. This gives you full TypeScript inference on args and argTypes.Named story exports
Named story exports
Each named export is a story. The export name becomes the story name in the Storybook UI (e.g.,
Primary, Secondary, Loading).Default export (Meta)
Default export (Meta)
The default export defines metadata for all stories in the file: which component to render, how to group it in the sidebar (
title), and which controls to expose (argTypes).argTypes controls
UseargTypes in the default export to configure the interactive controls panel:
| Control type | Use for |
|---|---|
'select' | Union string types with a fixed set of options |
'boolean' | Boolean props |
'text' | Free-form string props |
'number' | Numeric props |
'color' | Color string props |
Title conventions
Thetitle field in the default export controls where the story appears in the Storybook sidebar. Follow the package’s directory structure:
| Component location | Story title |
|---|---|
src/Common/Button | 'Common/Button' |
src/Containers/NavBar | 'Containers/NavBar' |
src/Icons/Social/GitHub | 'Icons/Social/GitHub' |
Related
Visual regression
Chromatic runs against your Storybook stories to catch visual changes.
Unit tests
Complement Storybook with programmatic unit tests.