--- name: tailwind-shadcn description: Tailwind CSS utility patterns with shadcn/ui component usage, theming via CSS variables, and responsive design. Use when styling components, installing shadcn components, implementing dark mode, or creating consistent design systems. --- # Tailwind CSS + shadcn/ui ## shadcn/ui Installation Components live in your codebase, not as dependencies: ```bash # Initialize shadcn npx shadcn@latest init # Add individual components npx shadcn@latest add button npx shadcn@latest add card npx shadcn@latest add form npx shadcn@latest add input npx shadcn@latest add accordion npx shadcn@latest add dialog npx shadcn@latest add dropdown-menu npx shadcn@latest add tabs ``` ## Component Usage ```tsx import { Button } from '@/components/ui/button'; import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; import { Accordion, AccordionContent, AccordionItem, AccordionTrigger, } from '@/components/ui/accordion'; // Button variants // Card composition Title Content here ``` ## CSS Variables Theming ```css /* globals.css */ @tailwind base; @tailwind components; @tailwind utilities; @layer base { :root { --background: 0 0% 100%; --foreground: 0 0% 3.9%; --primary: 0 0% 9%; --primary-foreground: 0 0% 98%; --secondary: 0 0% 96.1%; --muted: 0 0% 96.1%; --accent: 0 0% 96.1%; --border: 0 0% 89.8%; --ring: 0 0% 3.9%; --radius: 0.5rem; } [data-theme="earth"] { --background: 40 20% 98%; --foreground: 30 10% 15%; --primary: 30 30% 35%; --accent: 35 25% 90%; } } ``` ## Responsive Design ```tsx // Mobile-first approach
// Container pattern
{children}
``` ## Common Utility Patterns ```tsx // Flexbox centering
// Grid with gap
// Spacing
// Vertical spacing between children
// Horizontal spacing // Typography

// Hover/Focus states ``` ## cn() Utility ```tsx // lib/utils.ts import { type ClassValue, clsx } from 'clsx'; import { twMerge } from 'tailwind-merge'; export function cn(...inputs: ClassValue[]) { return twMerge(clsx(inputs)); } // Usage - merge classes conditionally

``` ## Animation Classes ```tsx // Built-in transitions
// Tailwind animations
// Loading skeleton
// Spinner
// Bounce effect ``` ## Dark Mode ```tsx // Toggle dark class on html element // Use dark: prefix

```