component-library
/component-library
Use when implementing or extending a shared component library — scaffolding new components with CVA variants, writing Storybook stories, wiring visual regression, or auditing existing components for state and a11y coverage.
- Author
- uw-ssec ↗
- Repository
- rse-plugins ↗
- Licence
- BSD-3-Clause
- Last repository change
- 14.10.2026
Assessment and security
- Files in this package
- 4
- Scripts
- 0
- HTML comments
- 0
- URLs in SKILL.md
- 4
No signals detected. Repository changed on 14.10.2026, without references to retired models or APIs.
BSD-3-Clause, otwarta.
What it does and when to use it
Use when implementing or extending a shared component library — scaffolding new components with CVA variants, writing Storybook stories, wiring visual regression, or auditing existing components for state and a11y coverage.
Original author description
Use when implementing or extending a shared component library — scaffolding new components with CVA variants, writing Storybook stories, wiring visual regression, or auditing existing components for state and a11y coverage.
How it works
- Build Order (with validation gates)
- Compound Components
- CVA Variant Definition
- Storybook Story (Button.stories.tsx)
- Playwright Visual Regression (tests/visual/button.spec.ts)
- Accessibility Audit (per-component gate)
- References
- Next Steps
SKILL.md preview
---
name: component-library
description: Use when implementing or extending a shared component library — scaffolding new components with CVA variants, writing Storybook stories, wiring visual regression, or auditing existing components for state and a11y coverage.
metadata:
references:
- references/composition-patterns.md
- references/state-management.md
- references/variant-systems.md
---
# Component Library
## Build Order (with validation gates)
1. **Tokens published** → verify with `rg -- '--color-' dist/tokens.css`.
2. **Layout primitives** (`Box`, `Stack`, `Flex`, `Grid`) → verify token consumption: `rg "#[0-9a-fA-F]{6}" src/primitives/` exits empty.
3. **Typography** (`Heading`, `Text`, `Label`).
4. **Button** → run a11y audit before proceeding: `npx test-storybook --url http://127.0.0.1:6006` zero violations.
5. **Form atoms** (`Input`, `Select`, `Checkbox`, `Radio`) → keyboard nav test passes.
6. **Containers** (`Card`, `Modal`, `Drawer`) → focus-trap test passes for Modal.
7. **Data** (`Table`, `List`) → axe-core audit on rendered story.
8. **Nav** (`Nav`, `Tabs`, `Breadcrumbs`).
Gate per tier: a11y audit clean + visual regression reviewed before next tier.
## Compound Components
Use the compound component pattern (context-based parent–child) for stateful widgets like `Select`, `Tabs`, `Accordion`, and `Modal`. The parent owns shared state via context; children consume it to coordinate behavior.
See [references/composition-patterns.md](references/composition-patterns.md) for complete React/Vue/Svelte examples including Select, Accordion, headless components, and polymorphic `as`-prop patterns.
## CVA Variant Definition
```ts
import { cva } from "class-variance-authority";
export const button = cva("inline-flex items-center font-medium rounded-md", {
variants: {
intent: { primary: "bg-primary text-white",
outline: "border-2 border-primary text-primary",
ghost: "text-primary hover:bg-primary/10" },
size: { sm: "h-8 px-3 text-sm", md: "h-10 px-4", lg: "h-12 px-6 text-lg" }
},
compoundVariants: [
{ intent: "ghost", size: "sm", class: "underline-offset-2" }
],
defaultVariants: { intent: "primary", size: "md" }
});
```
## Storybook Story (`Button.stories.tsx`)
```tsx
import type { Meta, StoryObj } from "@storybook/react";
import { Button } from "./Button";
const meta: Meta<typeof Button> = {
component: Button,
args: { children: "Click me" },
argTypes: { intent: { control: "select", options: ["primary","outline","ghost"] },
size: { control: "select", options: ["sm","md","lg"] } },
parameters: { a11y: { config: { rules: [{ id: "color-contrast", enabled: true }] } } }
};
export default meta;
export const Primary: StoryObj<typeof Button> = {};
export const Disabled: StoryObj<typeof Button> = { args: { disabled: true } };
export const Loading: StoryObj<typeof Button> = { args: { children: "Loading…" } };
```
## Playwright Visual Regression (`tests/visual/button.spec.ts`)
```ts
import { test, expect } from "@playwright/test";
const stories = ["primary", "disabled", "loading"];
for (const id of stories) {
test(`Button ${id} visual`, async ({ page }) => {
await page.goto(`http://127.0.0.1:6006/iframe.html?id=button--${id}`);
await expect(page.locator("#storybook-root"))
.toHaveScreenshot(`button-${id}.png`, { maxDiffPixelRatio: 0.01 });
});
}
```
Run: `npx playwright test tests/visual/ --update-snapshots` on intentional changes; fail-block on diffs in CI.
## Accessibility Audit (per-component gate)
```bash
# Headless axe-core on every Storybook story
npx test-storybook --url http://127.0.0.1:6006 --maxWorkers=2
# Or one-off:
npx @axe-core/cli http://127.0.0.1:6006/iframe.html?id=button--primary
```
Pass: zero serious/critical violations. Track moderate violations in issue tracker.
## References
- [Composition Patterns](references/composition-patterns.md) — compound, headless, polymorphic, refs
- [Variant Systems](references/variant-systems.md) — CVA, compound variants, type-safe APIs
- [State Management](references/state-management.md) — five UI states table, a11y requirements table, state machines
## Next Steps
- **[Design System Creation](../design-system-creation/SKILL.md)**: Ensure the library aligns with the broader design system governance
- **[Design Tokens](../design-tokens/SKILL.md)**: Consume tokens correctly and contribute component tokens back to the system
- **[Frontend Components](../frontend-components/SKILL.md)**: Implementation-specific guidance for React, Vue, and Svelte components
- **[Accessibility Audit](../accessibility-audit/SKILL.md)**: Validate component accessibility with automated and manual testing
Files in this package (4)
- SKILL.md 5 KB
- references/composition-patterns.md 14 KB
- references/state-management.md 14 KB
- references/variant-systems.md 11 KB
Versions
| Repository | Score | Licence |
|---|---|---|
| This page · uw-ssec/rse-plugins | 100 | BSD-3-Clause |
| Bbeierle12/Skill-MCP-Claude | 100 | MIT |
Database snapshot: 13.11.2026 · package version d3bb8aa7d9f3 (SHA-256 digest of the entire package)
Downloads in the last 30 days: 1 · ranking
Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.
Similar skills
- 95storybook-creation
Create or update Storybook stories for Daedalus React components. Use this when asked to write stories, visual tests, storybook entries, or component demos for new or existing features. - 100component-docs
Generate or update component documentation with usage examples, props tables, and Storybook stories. Use when documenting new components, creating usage examples, or setting up Storybook stories. - 100storybook-story-writing
Use when creating or modifying Storybook stories for components. Ensures stories follow CSF3 format, properly showcase component variations, and build successfully. - 100testing
Component testing — Vitest, Testing Library, jest-axe, Playwright e2e, Storybook stories, mock policy. Use when writing or augmenting tests — unit and interaction tests, accessibility assertions, end-to-end flows, Storybook stories, test setup and mocking — or when a component… - 100storybook-chromatic-builder
Stand up Storybook in the monorepo, build code components matching the Figma design system, generate stories for every component, set up Chromatic for visual regression testing, and wire Code Connect when the user's Figma plan supports it. Use this when the user wants to set up… - 100storybook-stories
Write Storybook stories for PostHog UI components. Covers the provider stack stories run inside, the key gotcha that tRPC/useHostTRPC queries never resolve in Storybook (so data-fetching components render empty), and the pure-presentational split that makes a component…