storybook-stories

Writes and maintains Storybook stories and interaction tests using CSF3 format. Covers component stories, play functions, visual regression testing with Chromatic, and accessibility testing. Use when creating component documentation, writing interaction tests, debugging test failures, configuring visual snapshots, or updating story structure. Use for CSF3, play functions, userEvent, Testing Library queries, Chromatic configuration, autodocs, MDX.

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "storybook-stories" with this command: npx skills add oakoss/agent-skills/oakoss-agent-skills-storybook-stories

Storybook Stories

Overview

Storybook is a frontend workshop for building UI components in isolation. Stories are written in Component Story Format 3 (CSF3), which uses object syntax with args for type-safe component documentation and testing.

When to use: Component documentation with live examples, interaction testing with play functions, visual regression testing, accessibility validation, design system maintenance, isolated component development.

When NOT to use: End-to-end testing (use Playwright/Cypress), API integration testing (use Vitest/Jest), full application testing (use browser automation), performance testing (use Lighthouse/WebPageTest).

Quick Reference

PatternAPIKey Points
Basic storyexport const Default: Story = { args }Use args for simple single components
Complex storyexport const Example: Story = { render }Use render for multi-component layouts
Meta configurationconst meta = { component, args } satisfies MetaDefine defaults and argTypes
Interaction testplay: async ({ canvas, userEvent, args })canvas and userEvent provided directly
User interactionawait userEvent.click(element)Always await userEvent methods
Query elementscanvas.getByRole('button')Prefer getByRole over other queries
Assertionsawait expect(args.onPress).toHaveBeenCalled()Use storybook/test assertions
beforeEach hookbeforeEach: async ({ args }) => {}Setup mocks before story renders
Play compositionawait OtherStory.play?.(context)Reuse setup across stories
Autodocstags: ['autodocs']Enable automatic documentation
Controls customizationargTypes: { variant: { control: 'select' } }Configure control panel
Decoratorsdecorators: [withTheme]Add wrappers or context providers
Parametersparameters: { layout: 'centered' }Configure addon behavior per story
Chromatic snapshotparameters: { chromatic: { delay: 300 } }Control visual regression captures
Disable snapshotparameters: { chromatic: { disableSnapshot: true } }Skip story in visual tests
A11y testingawait expect(button).toHaveAccessibleName()Validate accessible labels

Common Mistakes

MistakeCorrect Pattern
Using args with multi-component layoutsUse render for complex compositions
Not awaiting userEvent methodsAlways await: await userEvent.click(button)
Using within(canvasElement) manuallyDestructure canvas from play context directly
Using getByTestId firstPrefer getByRole, getByLabelText, getByText
Missing default args at meta levelAdd args to meta to prevent placeholder controls
Exposing non-serializable propsDisable className, ref, style in argTypes
Not composing play functionsReuse setup with await BaseStory.play?.(context)
Forgetting to mock callbacksUse fn() for event handlers: args: { onPress: fn() }
Missing accessible names for icon buttonsAdd aria-label or use aria-labelledby
Not scoping queries for portal contentUse within(canvasElement.ownerDocument.body)
Using boolean && for conditional renderingUse ternary in stories for consistent snapshots
Not waiting for animationsWrap assertions in waitFor for async state

Common Fixes

ProblemSolution
Controls show placeholdersAdd args at meta level with default values
Serialization errorDisable className, ref, style in argTypes
Portal element not foundSearch body instead of canvas
Animation timing issuesWrap assertions in waitFor
Multiple buttons foundAdd { name: '...' } to getByRole
A11y test failingAdd label prop or aria-label

Delegation

  • Story structure review: Use code-reviewer skill for CSF3 pattern validation
  • Accessibility audit: Use Explore agent to discover ARIA patterns across stories
  • Visual regression analysis: Use Task agent to investigate Chromatic failures

References

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Automation

playwright

No summary provided by upstream source.

Repository SourceNeeds Review
Automation

ui-ux-polish

No summary provided by upstream source.

Repository SourceNeeds Review
Automation

tanstack-form

No summary provided by upstream source.

Repository SourceNeeds Review
Automation

find-skills

No summary provided by upstream source.

Repository SourceNeeds Review