Tailwind CSS classes not applied after upgrading to v4

posée 2 months ago70 vuesen

3

After upgrading Tailwind to v4, most of my styles are gone. My tailwind.config.js still lists content paths. What changed?

Environnement :Tailwind CSS 4

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.

posée 2 months ago

1 réponse

4
✓
✓ Réponse acceptée

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é.

answered 2 months ago

Sign in and verify your email to post an answer.