shadcn

Manages shadcn/ui components, presets, and registries via the shadcn CLI.

Updated Sep 17, 2026
One-click install
npx skills add https://github.com/hkw2028/toy-project --skill shadcn-hkw2028
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: shadcn
Source: https://github.com/hkw2028/toy-project/tree/main/.agents/skills/shadcn
Command: npx skills add https://github.com/hkw2028/toy-project --skill shadcn-hkw2028

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Building UI with shadcn/ui requires knowing dozens of composition rules, CLI commands, preset workflows, and base-vs-radix API differences. This Skill injects project context and enforces correct component usage so generated code follows shadcn/ui conventions instead of hand-rolled markup. ## Core Features & Use Cases - Component Management: Search registries, add components, preview changes with --dry-run/--diff, and smart-merge upstream updates while preserving local modifications. - Preset & Theme Workflows: Initialize projects with named presets or preset codes, apply or switch presets with overwrite, partial, merge, or skip strategies. - Enforced UI Rules: Critical rules for forms (FieldGroup/Field), composition (Groups, Dialog titles, Card structure), icons (data-icon), styling (semantic tokens, gap-* spacing), and chat primitives (MessageScroller, Bubble, Attachment, Marker). - Use Case: Ask for a settings form with validation, and get code using FieldGroup, Field, data-invalid/aria-invalid states, and semantic color tokens matched to your project's base, icon library, and Tailwind version. ## Quick Start Ask the assistant to add a shadcn/ui dialog component to the project and build a profile editing form inside it.

Frequently Asked Questions about shadcn

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add shadcn/ui components to my project?

Run npx shadcn@latest add followed by component names, such as npx shadcn@latest add button card dialog. Use the package runner matching your project (pnpm dlx or bunx --bun), and preview changes first with --dry-run or --diff.

How do I apply or switch a shadcn preset code?

Use npx shadcn@latest apply <code> to overwrite an existing project's preset, or npx shadcn@latest init --preset <code> when initializing. Never decode preset codes manually; use preset decode, preset url, or preset resolve commands instead.

What is the difference between base and radix in shadcn/ui?

The base field in components.json determines the primitive library and component APIs. Radix uses asChild and type="single"/"multiple" props, while Base uses render props, multiple booleans, and array defaultValues for components like Select, ToggleGroup, Slider, and Accordion.

How do I update shadcn components without losing local changes?

Run npx shadcn@latest add <component> --dry-run to see affected files, then --diff <file> per file to compare upstream changes. Merge upstream updates manually where local modifications exist, and never use --overwrite without explicit approval.

Why should forms use FieldGroup and Field instead of divs?

FieldGroup and Field provide consistent layout, labeling, and validation state handling in shadcn/ui. Validation requires data-invalid on the Field and aria-invalid on the control, which raw div layouts with space-y-* do not wire up correctly.

Can I use community registries like Magic UI with shadcn?

Yes, add items with namespaced addresses like npx shadcn@latest add @magicui/shimmer-button or GitHub addresses like owner/repo/item. After adding, verify imports match your project's aliases and icon library, since third-party items may use default paths.