---
name: shadcn-ui
description: >-
  Use when building or styling UI in a React project that uses shadcn/ui (has a
  components.json): adding, composing or theming components, or applying a
  DESIGN.md or brand spec to shadcn.
---
# shadcn/ui (condensed)

Source: https://ui.shadcn.com/docs/skills (MIT). Official install: `pnpm dlx skills add shadcn/ui`.

Only relevant when a site is built in React with shadcn/ui; not for static HTML or image mockups.

## Principles
1. Use existing components first (`npx shadcn@latest search`).
2. Compose, don't reinvent (settings = Tabs + Card + form controls; dashboard = Sidebar + Card + Chart + Table).
3. Built-in variants before custom styles.
4. Semantic colours (`bg-primary`, `text-muted-foreground`), never raw `bg-blue-500`.

## Critical rules
- `className` for layout, not for overriding component colours; `flex` + `gap-*` instead of `space-x/y`; `cn()` for conditional classes; no manual `dark:` overrides or z-index on overlays.
- Forms: `FieldGroup` + `Field`; 2–7 options use `ToggleGroup`; validation via `data-invalid` and `aria-invalid`.
- Dialog/Sheet/Drawer always need a Title; full Card composition; `Avatar` always has `AvatarFallback`.
- Use components, not custom markup: `Alert`, `Empty`, `Separator`, `Skeleton`, `Badge`, `sonner`.
- Icons: use the project's `iconLibrary`; never assume lucide.

## Workflow
1. `npx shadcn@latest info --json` for project context.
2. Check installed components before `add`.
3. Read `npx shadcn@latest docs <component>` before using it.
4. `add` with `--dry-run`/`--diff`; never `--overwrite` without approval.
5. Never guess a registry.

## DESIGN.md to shadcn theme
Map the DESIGN.md tokens onto shadcn CSS variables (radius, shadows, fonts), restyle via `cva` variants, build a design-system page, and verify in a browser including dark mode.
