// Avoid when unnecessary
```
## Installation & CLI
```bash
# Create new project with visual style + primitive selection
npx shadcn create
# Initialize in existing project
pnpm dlx shadcn@latest init
# Add components
pnpm dlx shadcn@latest add button card form
# Add from community registries
npx shadcn add @acme/button @internal/auth-system
# View/search registries
npx shadcn view @acme/auth-system
npx shadcn search @tweakcn -q "dark"
npx shadcn list @acme
# Add MCP server for AI integration
npx shadcn@latest mcp init
# Update existing components
pnpm dlx shadcn@latest add button --overwrite
```
### Visual Styles
`npx shadcn create` offers 5 built-in visual styles:
- **Vega** - Classic shadcn/ui look
- **Nova** - Compact, reduced padding
- **Maia** - Soft and rounded, generous spacing
- **Lyra** - Boxy and sharp, pairs with mono fonts
- **Mira** - Dense, for data-heavy interfaces
These rewrite component code (not just CSS variables) to match the selected style.
## Troubleshooting
**Colors not updating:** Check CSS variable in globals.css → verify `@theme inline` includes the mapping → clear build cache.
**Dark mode flash on load:** Add `suppressHydrationWarning` to `` tag and ensure ThemeProvider wraps app with `attribute="class"`.
**Found `tailwind.config.js`:** Delete it. Run `npx @tailwindcss/upgrade` to auto-migrate to CSS-first config. All customization belongs in your CSS file via `@theme`, `@utility`, `@plugin`.
**Classes not detected:** Check `@source` directives cover your component paths. Never construct class names dynamically (see Critical Rules).
## Component Patterns
For detailed component patterns see [components.md](components.md):
- **Composition**: asChild pattern, data-slot attributes
- **Typography**: Heading scales, prose styles, inline code
- **Forms**: React Hook Form + Zod, Field component with FieldSet/FieldGroup
- **Icons**: Lucide icons with data-icon attributes
- **Inputs**: OTP, file, grouped inputs
- **Dialogs**: Modal patterns and composition
- **Data Tables**: TanStack table integration
- **Toasts**: Sonner notifications
- **Pitfalls**: cn() order, form defaultValues, dialog nesting, sticky, server/client
## Resources
See [theming.md](theming.md) for complete color system reference:
- `@theme` vs `@theme inline` (critical for dark mode)
- Status color extensions (success, warning, info)
- Z-index scale and animation tokens
- All base palettes (Neutral, Zinc, Slate, Stone, Gray)
## Summary
Key concepts:
- **v4 CSS-first only** - no `tailwind.config.js`, all config in CSS
- **Semantic colors only** - never use raw palette (`bg-blue-500`), always `bg-primary`
- **Always pair** `bg-*` with `text-*-foreground`
- **Never build class names dynamically** - use object lookup with complete strings
- **cn() order** - defaults first, consumer `className` last
- **No `transition-all`** - transition only specific properties
- **`@theme inline`** for dynamic theming, `@theme` for static tokens
- Author components as plain functions with `data-slot` (React 19)
- Apply CVA for component variants
- Use `motion-safe:` / `motion-reduce:` for animations
- Choose Radix UI or Base UI as primitive library
This skill targets Tailwind CSS v4.2 with shadcn/ui. For component-specific examples, see [components.md](components.md). For color system, see [theming.md](theming.md).