Storybook

From InugamiDev/ultrathink-oss · View interactive version

Storybook is an AI agent skill from the GitHub repository InugamiDev/ultrathink-oss. UI component development environment for building, testing, and documenting components in isolation

How to use this skill

Skill file

Storybook

UI component development environment for building, testing, and documenting components in isolation. Enables interactive exploration via args/controls, interaction testing with play functions, and visual regression via Chromatic.

When to Use

Key Patterns

CSF3 — Default export for metadata, named exports for stories:

const meta = { component: Button, tags: ['autodocs'] } satisfies Meta<typeof Button>;
export default meta;
type Story = StoryObj<typeof meta>;
export const Primary: Story = { args: { variant: 'primary', children: 'Click me' } };

Args & Controls — Expose props as interactive knobs via argTypes.

Decorators — Wrap with providers/theme: decorators: [(Story) => <Provider><Story /></Provider>]

Play Functions — Interaction tests using @storybook/test:

play: async ({ canvasElement }) => {
  const canvas = within(canvasElement);
  await userEvent.type(canvas.getByRole('textbox'), 'hello');
  await expect(canvas.getByRole('button')).toBeEnabled();
}

Autodocs — tags: ['autodocs'] on meta for automatic documentation pages.

Add-ons — addon-a11y, addon-viewport, addon-backgrounds, addon-actions.

Chromatic — Visual regression in CI. Exclude with chromatic: { disableSnapshot: true }.

MSW — Mock APIs per-story via parameters.msw.handlers.

Composition — Import from other Storybook instances via refs in .storybook/main.ts.

Anti-Patterns

| Anti-Pattern | Fix |

|---|---|

| Implementation details in play functions | Query by role/label, assert visible behavior |

| One mega-story with all variants | One story per meaningful state |

| Skipping autodocs tags | Add tags: ['autodocs'] by default |

| Hardcoded data without args | Define args and argTypes on meta |

| App-level providers imported globally | Scope decorators per-story or per-meta |

Related Skills

react | design-systems | testing-patterns | tailwindcss

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.