When to Use
- •Installing new shadcn/ui components
- •Customizing existing shadcn components
- •Ensuring UI consistency with project conventions
- •Modifying component styles or behavior
Critical Patterns
- •Use
pnpm dlx shadcn@latest add <component>to install components - •Components are typically located in
components/ui/or your project's designated UI components directory - •Follow
tailwind-4skill for styling conventions - •Follow
react-19skill for React patterns - •Use
cn()utility for conditional class merging - •Customize components by editing the
ui/files directly - •Import components from
@/components/ui/<component>
Code Examples
Adding a Button Component
bash
pnpm dlx shadcn@latest add button
tsx
import { Button } from '@/components/ui/button'
export function MyComponent() {
return <Button variant="default">Click me</Button>
}
Customizing a Component
Edit components/ui/button.tsx to add custom variants or styles.
Commands
bash
# Add a new component pnpm dlx shadcn@latest add <component> # Initialize shadcn (if not already done) pnpm dlx shadcn@latest init
Resources
- •Configuration: See components.json for shadcn configuration
- •Documentation: See references/ for local docs