$npx -y skills add sabahattink/antigravity-fullstack-hq --skill tailwind-patternsTailwind CSS v4 patterns, component styling, dark mode, responsive design, and design system integration. Use when styling components or reviewing CSS.
| 1 | # Tailwind Patterns |
| 2 | |
| 3 | ## Core Approach |
| 4 | |
| 5 | - Utility-first: compose classes, don't write custom CSS |
| 6 | - Extract components, not classes (use React components, not `@apply`) |
| 7 | - Consistent spacing/color via design tokens |
| 8 | |
| 9 | ## Component Patterns |
| 10 | |
| 11 | ### Button Variants |
| 12 | |
| 13 | ```tsx |
| 14 | const buttonVariants = { |
| 15 | primary: 'bg-blue-600 hover:bg-blue-700 text-white', |
| 16 | secondary: 'bg-gray-100 hover:bg-gray-200 text-gray-900', |
| 17 | danger: 'bg-red-600 hover:bg-red-700 text-white', |
| 18 | ghost: 'hover:bg-gray-100 text-gray-700', |
| 19 | } |
| 20 | |
| 21 | interface ButtonProps { |
| 22 | variant?: keyof typeof buttonVariants |
| 23 | size?: 'sm' | 'md' | 'lg' |
| 24 | children: React.ReactNode |
| 25 | } |
| 26 | |
| 27 | export const Button = ({ variant = 'primary', size = 'md', children }: ButtonProps) => { |
| 28 | const sizes = { sm: 'px-3 py-1.5 text-sm', md: 'px-4 py-2', lg: 'px-6 py-3 text-lg' } |
| 29 | return ( |
| 30 | <button className={`${buttonVariants[variant]} ${sizes[size]} rounded-lg font-medium transition-colors`}> |
| 31 | {children} |
| 32 | </button> |
| 33 | ) |
| 34 | } |
| 35 | ``` |
| 36 | |
| 37 | ### Responsive Design |
| 38 | |
| 39 | ```tsx |
| 40 | // Mobile-first approach |
| 41 | <div className=" |
| 42 | flex flex-col // mobile: stack |
| 43 | md:flex-row // tablet: row |
| 44 | lg:grid lg:grid-cols-3 // desktop: 3 columns |
| 45 | gap-4 |
| 46 | "> |
| 47 | ``` |
| 48 | |
| 49 | ### Dark Mode |
| 50 | |
| 51 | ```tsx |
| 52 | // Use dark: prefix |
| 53 | <div className="bg-white dark:bg-gray-900 text-gray-900 dark:text-gray-100"> |
| 54 | <p className="text-gray-600 dark:text-gray-400"> |
| 55 | Secondary text |
| 56 | </p> |
| 57 | </div> |
| 58 | ``` |
| 59 | |
| 60 | ## Design Tokens (v4) |
| 61 | |
| 62 | ```css |
| 63 | /* In CSS — v4 uses CSS variables */ |
| 64 | @theme { |
| 65 | --color-primary: oklch(0.6 0.2 250); |
| 66 | --color-primary-foreground: oklch(1 0 0); |
| 67 | --spacing-page: 1.5rem; |
| 68 | --radius-card: 0.75rem; |
| 69 | } |
| 70 | ``` |
| 71 | |
| 72 | ```tsx |
| 73 | // Use in components |
| 74 | <div className="bg-primary text-primary-foreground p-page rounded-card"> |
| 75 | ``` |
| 76 | |
| 77 | ## Common Patterns |
| 78 | |
| 79 | ### Card |
| 80 | |
| 81 | ```tsx |
| 82 | <div className="rounded-xl border border-gray-200 bg-white p-6 shadow-sm dark:border-gray-800 dark:bg-gray-900"> |
| 83 | ``` |
| 84 | |
| 85 | ### Form Input |
| 86 | |
| 87 | ```tsx |
| 88 | <input className="w-full rounded-lg border border-gray-300 bg-white px-4 py-2.5 text-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-500/20 dark:border-gray-700 dark:bg-gray-900" /> |
| 89 | ``` |
| 90 | |
| 91 | ### Skeleton Loader |
| 92 | |
| 93 | ```tsx |
| 94 | <div className="animate-pulse rounded-lg bg-gray-200 dark:bg-gray-700 h-4 w-3/4" /> |
| 95 | ``` |
| 96 | |
| 97 | ## Forbidden Patterns |
| 98 | |
| 99 | ```tsx |
| 100 | // ❌ Never use @apply for component styles |
| 101 | .btn { @apply px-4 py-2; } // extract React component instead |
| 102 | |
| 103 | // ❌ Arbitrary values when token exists |
| 104 | <div className="text-[#3b82f6]" /> // use text-blue-500 |
| 105 | |
| 106 | // ❌ Inline styles with Tailwind |
| 107 | <div style={{ color: 'blue' }} className="..."> |
| 108 | ``` |