0

I’m using Nuxt 4 (RC) with Tailwind CSS. Tailwind is working fine for default utilities (bg-red-500, text-xl, etc.), but my custom bg-primary color isn’t applied.

Here’s my setup:

nuxt.config.ts

import tailwindcss from "@tailwindcss/vite";

export default defineNuxtConfig({
  compatibilityDate: "2025-07-15",
  css: ['~/assets/css/main.css'],
  vite: {
    plugins: [tailwindcss()],
  },
});

assets/css/main.css

@import "tailwindcss";

tailwind.config.js

/** @type {import('tailwindcss').Config} */
export default {
  content: [
    './app/**/*.{js,ts,vue}',
    './components/**/*.{js,ts,vue}',
    './layouts/**/*.{js,ts,vue}',
    './pages/**/*.{js,ts,vue}',
    './plugins/**/*.{js,ts}',
    './nuxt.config.{js,ts}',
    './**/*.vue'
  ],
  theme: {
    extend: {
      colors: {
        primary: 'rgb(29, 78, 216)',
      },
    },
  },
  plugins: [],
};


<h1 class="text-3xl font-bold bg-primary text-white">
    Hello World!
</h1>

But the background stays transparent. Default Tailwind colors work fine, only my custom color is ignored.

Is there something different with Nuxt 4’s Tailwind integration (vite plugin, config paths, etc.) that I’m missing?

1

1 Answer 1

2

It seems like you're using Tailwind v4. In v4, the JavaScript configuration is obsolete, sueprceded by configuration in CSS. Thus, as per the documentation, you'd add your own color theme token like so:

@import "tailwindcss";

@theme {
  --color-primary: rgb(29, 78, 216);
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.