Tailwind CSS classes not applied after upgrading to v4
posée 2 months ago70 vuesen
After upgrading Tailwind to v4, most of my styles are gone. My tailwind.config.js still lists content paths. What changed?
Diagnostic IA
Généré par IA. Ce n'est pas une réponse — la communauté ci-dessous le confirme ou le corrige. Vérifiez toujours avant de vous y fier.
1 réponse
Tailwind v4 changed the setup. Configuration moved into CSS, and content detection is automatic.
1. Replace the old @tailwind base; @tailwind components; @tailwind utilities; with a single import:
@import "tailwindcss";
2. Move theme customizations into CSS:
@theme {
--color-brand: #00209f;
--font-display: "Inter", sans-serif;
}
3. The PostCSS plugin is now @tailwindcss/postcss (or use @tailwindcss/vite).
4. To keep an existing JS config during migration, reference it with @config "./tailwind.config.js";.
Run npx @tailwindcss/upgrade in a clean git branch. It automates most of this, including renamed utilities.
Connectez-vous pour dire si ça a marché.
Sign in and verify your email to post an answer.