| name | shadcn-component-installer |
| description | Install and verify shadcn/ui components using the official CLI. Use when the user requests to add shadcn components, needs UI components like button, dialog, table, form elements, or mentions installing shadcn components. Always use the CLI installation method - never manually create shadcn component code. |
| keywords | shadcn, shadcn-ui, radix, ui-components, install-component, npx-shadcn, tailwind, component-install |
shadcn/ui Component Installer
Overview
This skill ensures proper installation and verification of shadcn/ui components using the official CLI. It prevents manual component creation and validates installations.
Critical Rules
❌ NEVER Manually Create Components
NEVER write shadcn component code manually. Always use the CLI:
pnpm dlx shadcn@latest add <component-name>
✅ Always Use CLI Installation
shadcn/ui provides an official CLI that:
- Installs components with correct dependencies
- Adds required CSS variables
- Ensures proper configuration
- Maintains consistency
Installation Process
Step 1: Install Component
Use the shadcn CLI to install components:
pnpm dlx shadcn@latest add button
pnpm dlx shadcn@latest add button dialog card
Common components:
button - Button component
dialog - Dialog/modal component
input - Input field
form - Form components
select - Select dropdown
table - Data table
dropdown-menu - Dropdown menu
popover - Popover component
toast - Toast notifications
sheet - Sheet/drawer component
tabs - Tabs component
card - Card component
badge - Badge component
avatar - Avatar component
checkbox - Checkbox input
radio-group - Radio button group
switch - Switch toggle
slider - Slider input
textarea - Textarea input
label - Label component
separator - Separator line
For complete list, see references/component-list.md.
Step 2: Verify Installation Location
After installation, verify the component is in the correct location:
ls -la src/components/atoms/<component-name>.tsx
Expected location:
- All shadcn components →
src/components/atoms/
- File naming:
<component-name>.tsx (kebab-case)
Step 3: Check Dependencies
Verify all required dependencies were installed:
cat package.json | grep -A 20 "dependencies"
Common dependencies shadcn components need:
@radix-ui/* - Radix UI primitives
class-variance-authority - CVA for variants
clsx - Conditional classes
tailwind-merge - Merge Tailwind classes
lucide-react - Icons (if using icon components)
If missing dependencies, install them:
pnpm install
Step 4: Verify CSS Variables
Check if required CSS variables are present in src/styles/tailwind.css:
cat src/styles/tailwind.css
Required CSS variables structure:
@layer base {
:root {
--background: 0 0% 100%;
--foreground: 222.2 47.4% 11.2%;
--card: 0 0% 100%;
--card-foreground: 222.2 47.4% 11.2%;
--popover: 0 0% 100%;
--popover-foreground: 222.2 47.4% 11.2%;
--primary: 222.2 47.4% 11.2%;
--primary-foreground: 210 40% 98%;
--secondary: 210 40% 96.1%;
--secondary-foreground: 222.2 47.4% 11.2%;
--muted: 210 40% 96.1%;
--muted-foreground: 215.4 16.3% 46.9%;
--accent: 210 40% 96.1%;
--accent-foreground: 222.2 47.4% 11.2%;
--destructive: 0 84.2% 60.2%;
--destructive-foreground: 210 40% 98%;
--border: 214.3 31.8% 91.4%;
--input: 214.3 31.8% 91.4%;
--ring: 222.2 47.4% 11.2%;
--radius: 0.5rem;
}
.dark {
--background: 222.2 84% 4.9%;
--foreground: 210 40% 98%;
}
}
If CSS variables are missing, the shadcn CLI usually adds them automatically. If not, check the component documentation for required variables.
For complete CSS setup, see references/css-setup.md.
Post-Installation Checklist
After installing a component, verify:
Verification Commands
Run these commands after installation:
ls src/components/atoms/ | grep <component-name>
cat package.json | grep "@radix-ui"
cat src/styles/tailwind.css | grep "layer base"
pnpm type
Common Issues & Solutions
Issue: Component not found after installation
Solution:
- Check if installation completed successfully
- Verify component is in
components.json config
- Re-run installation command
Issue: Missing dependencies
Solution:
pnpm install
Issue: CSS variables missing
Solution:
- Check
tailwind.css for @layer base
- Manually add missing variables from shadcn docs
- Restart dev server
Issue: TypeScript errors
Solution:
- Check all dependencies installed:
pnpm install
- Restart TypeScript server
- Check import paths are correct
Usage Examples
Example 1: Installing Button Component
pnpm dlx shadcn@latest add button
ls src/components/atoms/button.tsx
cat package.json | grep "class-variance-authority"
import { Button } from '@/components/atoms/button'
<Button variant="default">Click me</Button>
Example 2: Installing Form Components
pnpm dlx shadcn@latest add form input label
ls src/components/atoms/ | grep -E "form|input|label"
import { Form } from '@/components/atoms/form'
import { Input } from '@/components/atoms/input'
import { Label } from '@/components/atoms/label'
Example 3: Installing Dialog Component
pnpm dlx shadcn@latest add dialog
cat package.json | grep "@radix-ui/react-dialog"
pnpm install
import { Dialog, DialogContent, DialogHeader } from '@/components/atoms/dialog'
When Creating Molecule Components
After installing shadcn atoms, you may create molecule wrappers:
- shadcn component installed in
src/components/atoms/
- Create custom wrapper in
src/components/molecules/<name>/
- Import and extend the atom component
- Add business logic and custom behavior
Example:
import { Avatar } from '@/components/atoms/avatar'
export function UserAvatar({ user }: { user: User }) {
return (
<Avatar>
<AvatarImage src={user.avatarUrl} />
<AvatarFallback>{user.initials}</AvatarFallback>
</Avatar>
)
}
Summary
Key Points:
- ✅ Always use
pnpm dlx shadcn@latest add <component>
- ❌ Never manually create shadcn components
- ✅ Verify installation in
src/components/atoms/
- ✅ Check dependencies and CSS variables
- ✅ Run type check after installation
- ✅ Test component import before using
For more details, see: