// Review Tailwind CSS v4 patterns for configuration, theming, and utility usage. Use when reviewing CSS files, Vite configs, or components using Tailwind.
| name | reviewing-tailwind-patterns |
| description | Review Tailwind CSS v4 patterns for configuration, theming, and utility usage. Use when reviewing CSS files, Vite configs, or components using Tailwind. |
| review | true |
| allowed-tools | Read, Grep, Glob |
Review Tailwind CSS v4 implementations for correct configuration, modern patterns, and best practices.
Check build tool configuration:
@tailwindcss/vite for Vite projects (preferred over PostCSS)@tailwindcss/postcss for other build toolstailwind.config.js file (v4 uses CSS configuration)@tailwindcss/postcss)Vite config pattern:
import tailwindcss from '@tailwindcss/vite';
export default defineConfig({
plugins: [react(), tailwindcss()],
});
PostCSS config pattern:
export default {
plugins: {
'@tailwindcss/postcss': {},
},
};
Check import syntax:
@import 'tailwindcss'; (not @tailwind directives)Correct pattern:
@import 'tailwindcss';
@theme {
--font-sans: 'Inter', sans-serif;
--color-primary: oklch(0.65 0.25 270);
--spacing-18: 4.5rem;
@keyframes fade-in {
0% { opacity: 0; }
100% { opacity: 1; }
}
}
Anti-patterns:
@tailwind base;
@theme {
--color-primary: #3b82f6;
}
@keyframes fade-in {
0% { opacity: 0; }
100% { opacity: 1; }
}
Check namespace usage:
--color-* prefix--font-* prefix--spacing-* prefix--radius-* prefix--animate-* prefixGood pattern:
@theme {
--color-primary: oklch(0.65 0.25 270);
--color-secondary: oklch(0.75 0.22 320);
--color-success: oklch(0.72 0.15 142);
--color-error: oklch(0.65 0.22 25);
}
Anti-pattern:
@theme {
--primary: oklch(0.65 0.25 270);
--blue: oklch(0.75 0.22 320);
--my-color: oklch(0.72 0.15 142);
}
Check color definitions:
Correct:
--color-brand: oklch(0.65 0.25 270);
Incorrect:
--color-brand: #3b82f6;
--color-accent: rgb(168, 85, 247);
--color-success: hsl(142, 76%, 36%);
Check for v3 patterns:
bg-opacity-* utilities (use bg-{color}/{opacity})flex-shrink-* (use shrink-*)flex-grow-* (use grow-*)shadow-sm (use shadow-xs)border)ring-3)v4 patterns:
<div class="bg-black/50"></div>
<div class="shrink-0 grow"></div>
<div class="shadow-xs"></div>
<div class="border border-gray-200"></div>
<input class="ring-3 ring-blue-500" />
v3 anti-patterns:
<div class="bg-black bg-opacity-50"></div>
<div class="flex-shrink-0 flex-grow"></div>
<div class="shadow-sm"></div>
<div class="border"></div>
<input class="ring" />
Check container query usage:
@container or @container/{name}@ prefixCorrect pattern:
<div class="@container/main">
<div class="grid-cols-1 @md/main:grid-cols-2 @lg/main:grid-cols-3"></div>
</div>
Anti-pattern:
<div>
<div class="grid-cols-1 @md:grid-cols-2"></div>
</div>
Check @utility usage:
@utility (not @layer utilities)--value() functions correctlyCorrect pattern:
@utility tab-* {
tab-size: --value(--tab-size- *);
tab-size: --value(integer);
tab-size: --value([integer]);
}
Anti-pattern:
@layer utilities {
.tab-4 {
tab-size: 4;
}
}
Check animation patterns:
--animate-* prefixstarting: variant for entry animationsCorrect pattern:
@theme {
--animate-fade-in: fade-in 0.3s ease-out;
@keyframes fade-in {
0% { opacity: 0; }
100% { opacity: 1; }
}
}
Anti-pattern:
@keyframes fade-in {
0% { opacity: 0; }
100% { opacity: 1; }
}
@theme {
--animate-fade-in: fade-in;
}
Check component reusability:
Good pattern:
<div class="@container">
<article class="bg-white dark:bg-gray-900 rounded-lg p-4 @md:p-6">
<h2 class="text-lg @md:text-xl font-bold text-primary">Title</h2>
<p class="text-sm @md:text-base text-gray-600 dark:text-gray-300">Content</p>
</article>
</div>
Check content detection:
@source only when needed@source notWhen to use @source:
@source "../packages/ui";
@source not "./legacy";
Don't do this:
@import 'tailwindcss' source(none);
@source "./src/**/*.{html,js,jsx,ts,tsx}";
@tailwind instead of @import@tailwindcss/postcss## Tailwind v4 Review
### Configuration
- [ ] Build tool: [Vite/PostCSS/Other]
- [ ] Using correct plugin
- [ ] No v3 config file
### CSS
- [ ] Correct import syntax
- [ ] Theme variables properly namespaced
- [ ] Colors using oklch()
- [ ] Animations within @theme
### Components
- [ ] Container queries used correctly
- [ ] Semantic naming
- [ ] No v3 utility patterns
### Issues Found
1. [Priority] [Description]
2. [Priority] [Description]
### Recommendations
- [Specific recommendation]
- [Specific recommendation]