--- description: Tailwind CSS utility-first design system patterns alwaysApply: false globs: **/*.{vue,html,jsx,tsx} --- # Tailwind CSS Mastery ## Core Principles ### 1. Embrace Utility Classes Don't fight against utilities - they're your superpower. ### 2. Extract Components When You Repeat Create component classes only after repeating a pattern **3+ times**. ### 3. Mobile-First Responsive Design Always start mobile, progressively enhance for larger screens. ```html
Content
Dark text on light
Hard to read!
``` ## Custom Component Classes Only extract after 3+ repetitions: ```css @layer components { .btn-primary { @apply px-6 py-3 bg-primary text-white rounded-lg font-semibold; @apply hover:bg-primary-dark transition-colors duration-200; @apply focus:outline-none focus:ring-2 focus:ring-primary-focus; } } ``` ## Summary Checklist - ✅ Start mobile-first, enhance for larger screens - ✅ Use design tokens (extend Tailwind config) - ✅ Follow 4px spacing grid - ✅ Extract components after 3+ repetitions - ✅ Keep utility classes in HTML - ✅ Ensure color contrast for accessibility - ✅ Use transitions for smooth interactions - ✅ Configure PurgeCSS for production