domains / design / shadcn-ui-component-guidance / shadcn
The two copies address different layers of the same skill. The bergside copy is a design-system authoring guide: it defines visual foundations (typography, color tokens, spacing), accessibility tone, and a workflow for writing design-system documentation. The sickn33 copy is an implementation/CLI guide: it covers the shadcn CLI, project context, component composition rules, Tailwind styling constraints, form patterns, and icon usage. Neither copy contains the other's material steps, and crowning one would hide a real alternative. They overlap only in the general goal of producing consistent shadcn/ui output.
| Repository | Path |
|---|---|
| bergside/awesome-design-skills | skills/shadcn/SKILL.md |
| sickn33/agentic-awesome-skills | plugins/agentic-awesome-skills-claude/skills/shadcn/SKILL.md |
| Role | Repository | Path |
|---|---|---|
| peer | bergside/awesome-design-skills | skills/shadcn/SKILL.md |
| peer | sickn33/agentic-awesome-skills | plugins/agentic-awesome-skills-claude/skills/shadcn/SKILL.md |
| adapter | sickn33/agentic-awesome-skills | plugins/agentic-awesome-skills/skills/shadcn/SKILL.md |
| adapter | sickn33/agentic-awesome-skills | plugins/agentic-bundle-web-app/skills/shadcn/SKILL.md |
| adapter | sickn33/agentic-awesome-skills | skills/shadcn/SKILL.md |
# shadcn/ui Skill ## Purpose Provide both design-system guidance and implementation-ready component patterns for shadcn/ui projects. ## When to Use - Adding new components from shadcn/ui or community registries. - Styling, composing, or debugging existing shadcn/ui components. - Initializing a new project or switching design system presets. - Authoring or reviewing design-system documentation for a shadcn/ui-based product. ## CLI and Project Context - Run all CLI commands using the project's package runner: `npx shadcn@latest`, `pnpm dlx shadcn@latest`, or `bunx --bun shadcn@latest` based on the project's `packageManager`. - Retrieve project config and installed components with `npx shadcn@latest info --json`. - Get component documentation with `npx shadcn@latest docs <component>`. - Search registries before writing custom UI: `npx shadcn@latest search`. - Never decode or fetch preset codes manually; pass them directly to `npx shadcn@latest init --preset <code>`. ## Design Foundations - Visual style: minimal, clean. - Typography: use the project's configured font stack (commonly Geist for primary/display, Fira Code for mono) and a consistent type scale. - Color: use semantic tokens (`bg-primary`, `text-muted-foreground`, `bg-background`) rather than raw hex or Tailwind color values. - Spacing: follow a consistent spacing rhythm (e.g., 4/8/12/16/24/32) and avoid inconsistent gaps. - Accessibility: target WCAG 2.2 AA, keyboard-first interactions, and visible focus states. ## Implementation Rules ### Styling and Tailwind - Use `className` for layout, not for overriding component colors or typography. - Do not use `space-x-*` or `space-y-*`; use `flex` with `gap-*`. - Use `size-*` when width and height are equal. - Use `truncate` shorthand instead of `overflow-hidden text-ellipsis whitespace-nowrap`. - Do not use manual `dark:` color overrides; use semantic tokens. - Use `cn()` for conditional classes. - Do not set manual `z-index` on overlay components (Dialog, Sheet, Popover, etc.). ### Forms and Inputs - Use `FieldGroup` + `Field` for form layout; never raw `div` with `space-y-*` or `grid gap-*`. - Use `InputGroupInput`/`InputGroupTextarea` inside `InputGroup`; never raw `Input`/`Textarea`. - Use `InputGroup` + `InputGroupAddon` for buttons inside inputs. - Use `ToggleGroup` for option sets of 2–7 choices. - Use `FieldSet` + `FieldLegend` for grouping related checkboxes/radios. - Field validation: `data-invalid` on `Field`, `aria-invalid` on the control. For disabled: `data-disabled` on `Field`, `disabled` on the control. ### Component Composition - Items must be inside their Group: `SelectItem` → `SelectGroup`, `DropdownMenuItem` → `DropdownMenuGroup`, `CommandItem` → `CommandGroup`. - Use `asChild` (radix) or `render` (base) for custom triggers; check the `base` field from `npx shadcn@latest info`. - Dialog, Sheet, and Drawer always need a Title (`DialogTitle`, `SheetTitle`, `DrawerTitle`); use `className="sr-only"` if visually hidden. - Use full Card composition: `CardHeader`/`CardTitle`/`CardDescription`/`CardContent`/`CardFooter`. - Button has no `isPending`/`isLoading`; compose with `Spinner` + `data-icon` + `disabled`. - `TabsTrigger` must be inside `TabsList`. - `Avatar` always needs `AvatarFallback`. ### Use Components, Not Custom Markup - Check if a component exists before writing a styled `div`. - Callouts use `Alert`; empty states use `Empty`; toasts via `sonner` (`toast()`). - Use `Separator` instead of `<hr>` or `<div className="border-t">`. - Use `Skeleton` for loading placeholders; no custom `animate-pulse` divs. - Use `Badge` instead of custom styled spans. ### Icons - Icons in `Button` use `data-icon="inline-start"` or `data-icon="inline-end"`. - Do not add sizing classes to icons inside components; components handle icon sizing via CSS. - Pass icons as objects, not string keys. ## Design-System Authoring Workflow When generating design-system guidance for a shadcn/ui project: 1. Restate the design intent in one sentence before proposing rules. 2. Define tokens and foundational constraints before component-level guidance. 3. Specify component anatomy, states, variants, and interaction behavior. 4. Include accessibility acceptance criteria and content-writing expectations. 5. Add anti-patterns and migration notes for existing inconsistent UI. 6. End with a QA checklist that can be executed in code review. ## Required Output Structure for Design-System Docs - Context and goals - Design tokens and foundations - Component-level rules (anatomy, variants, states, responsive behavior) - Accessibility requirements and testable acceptance criteria - Content and tone standards with examples - Anti-patterns and prohibited implementations - QA checklist ## Component Rule Expectations - Define required states: default, hover, focus-visible, active, disabled, loading, error (as relevant). - Describe interaction behavior for keyboard, pointer, and touch. - State spacing, typography, and color-token usage explicitly. - Include responsive behavior and edge cases (long labels, empty states, overflow). ## Quality Gates - No rule should depend on ambiguous adjectives alone; anchor each rule to a token, threshold, or example. - Every accessibility statement must be testable in implementation. - Prefer system consistency over one-off local optimizations. - Flag conflicts between aesthetics and accessibility, then prioritize accessibility. - Use "must" for non-negotiable rules and "should" for recommendations. - Pair every do-rule with at least one concrete don't-example. - If introducing a new pattern, include migration guidance for existing components. ## Conflicts - The bergside copy prescribes a fixed color palette (primary=#000000, secondary=#111111, success=#16A34A, warning=#D97706, danger=#DC2626, surface=#FFFFFF, text=#111827) and a fixed typography scale (12/14/16/20/24/32). The sickn33 copy does not prescribe a fixed palette or type scale and instead defers to the project's shadcn config and semantic tokens. When authoring design-system docs, use the project's actual tokens; when implementing components, use semantic tokens from the project config.