This skill should be used when the user asks to "add a component", "use shadcn", "install Button", "create Dialog", "add Form", "use DataTable", "implement dark mode toggle", "use cn utility", or discusses UI components, component libraries, or accessible components. Always use the latest shadcn/ui version and modern patterns.
This skill provides guidance for building interfaces with shadcn/ui, focusing on always using the latest version and modern patterns.
Philosophy: Copy and own your components. Use the
new-yorkstyle. Leverage Radix UI primitives for accessibility.
| Feature | Modern Approach | Legacy (Avoid) |
|---|---|---|
| Style | new-york | default (deprecated) |
| Toast | sonner | toast component |
| Animation | CSS/tw-animate-css | tailwindcss-animate |
| forwardRef | Direct ref prop (React 19) | forwardRef wrapper |
npx shadcn@latest init
Configuration prompts:
# Add individual components
npx shadcn@latest add button
npx shadcn@latest add card dialog form input
# Add multiple components
npx shadcn@latest add button card dialog form input label textarea
Merge Tailwind classes conditionally:
import { cn } from "@/lib/utils"
interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
variant?: 'default' | 'destructive' | 'outline'
size?: 'sm' | 'md' | 'lg'
}
export function Button({
className,
variant = 'default',
size = 'md',
...props
}: ButtonProps) {
return (
<button
className={cn(
// Base styles
"inline-flex items-center justify-center rounded-md font-medium transition-colors",
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
"disabled:pointer-events-none disabled:opacity-50",
// Variants
variant === 'default' && "bg-primary text-primary-foreground hover:bg-primary/90",
variant === 'destructive' && "bg-destructive text-destructive-foreground hover:bg-destructive/90",
variant === 'outline' && "bor...