nuxt-modules / tailwindcss

Tailwind CSS module for Nuxt
https://tailwindcss.nuxtjs.org
MIT License
1.66k stars 180 forks source link

Tailwind class not applying #863

Closed fachryadhitya closed 2 months ago

fachryadhitya commented 2 months ago

Environment

Reproduction

https://stackblitz.com/edit/nuxt-starter-8grvpb?file=app.vue

Describe the bug

Hello, I want to report a bug that is related to tailwind arbitrary class. In the example I shared below, I have dynamic class definition that will be resolved according to the status value. In this case, you can see that in paid status, the bgColor is bg-[#d1fab3]. But after I specified the value directly, you can see that the color applied. I think this is a bug as The color should have been applied even before I directly use the bgColor value (without import).

Attached video too here:

https://github.com/nuxt-modules/tailwindcss/assets/58819726/5d45f22d-29c9-4052-a57e-6c76f9207743

Additional context

No response

Logs

No Error Logs
ineshbose commented 2 months ago

Hi, thanks for opening an issue on this repository.

I see you have a common/ directory that contains your styling classes. This isn't a standard Nuxt directory that the module would know about, so it's not added to the content configuration. You can fix this by adding this line to your nuxt.config:

// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
  devtools: { enabled: false },
  modules: ['@nuxtjs/tailwindcss'],
+  tailwindcss: { config: { content: ['./common/**/*.ts'] }}
});