content icon indicating copy to clipboard operation
content copied to clipboard

Tailwind classes applied via MDC component are not generated

Open stijns96 opened this issue 3 months ago • 8 comments

Environment

  • Operating System: Darwin
  • Node Version: v22.15.0
  • Nuxt Version: -
  • CLI Version: 3.29.3
  • Nitro Version: -
  • Package Manager: [email protected]
  • Builder: -
  • User Config: -
  • Runtime Modules: -
  • Build Modules: -

Version

v3

Reproduction

::steps{level="4" class="[&>h4]:text-base"}

#### Test

::

Description

When adding a class to an MDC Vue component rendered, the class is correctly applied to the resulting HTML element. However, Tailwind doesn’t generate the corresponding styles, it seems Tailwind never “sees” these dynamically applied classes.

If I manually apply the same class inside app.vue, the styles are generated as expected, which confirms that Tailwind is functioning correctly but simply not detecting the class when it’s applied through the MDC-rendered component.

Not sure tho wether this is due Nuxt UI, Nuxt Content or Tailwind

Additional context

No response

Logs


stijns96 avatar Oct 16 '25 07:10 stijns96

Got the same issue after upgrading from 2.x to 3.7.1. Neither I'm sure whether this is related to Nuxt Content, Nuxt Tailwind or Tailwind itself. There is a related issue on Tailwind's github.

tegola avatar Oct 24 '25 09:10 tegola

Cross-posting from my related issue #3319: The config tweak suggested by @farnabaz

https://github.com/nuxt/content/issues/3319#issuecomment-2827938282

fixed the prose styling regression there. worth a shot!

aryamaddel avatar Oct 26 '25 14:10 aryamaddel

Have you tried to add content directory? Just like what we have in Content module docs project

@source "../../../content/**/*";

farnabaz avatar Oct 27 '25 14:10 farnabaz

The @source "..." syntax is tailwind 4 only, isn't it? I'm using Nuxt Tailwind 6.14, which still uses Tailwind 3.

tegola avatar Oct 27 '25 17:10 tegola

I see, As you are using tailwind 3 try adding content files to tailwind.config file. Checkout https://tailwindcss.nuxtjs.org/tailwindcss/configuration#default-configuration

!! Content module used to add these configuration and handle tailwind v3 but this no more the case and you need to tell tailwind v3 to check the content files for classes

farnabaz avatar Oct 29 '25 13:10 farnabaz

  • This syntax:
content: {
    files: [
      "{srcDir}/content/**/*.md",
      ...
    ]
  },

ends up with this error:

WARN  warn - The glob pattern {srcDir}/content/**/*.md in your Tailwind CSS configuration is invalid.
WARN  warn - Update it to srcDir/content/**/*.md to silence this warning.
  • Changing {srcDir} into srcDir makes no sense since it would be treated as the dir name, but I tried anyway, thinking there was some kind of magic parameter name: doesn't work.

  • Using ./content/**/*.md doesn't work either.

  • Specifying the relative option also doesn't work:

content: {
    relative: true,
    files: [
      "./content/**/*.md",
      ...
    ]
  },

tegola avatar Oct 30 '25 16:10 tegola

@tegola Is your repository public? Or can you share a simple reproduction?

farnabaz avatar Oct 31 '25 08:10 farnabaz

Sorry for the delay. I cannot share my repo neither I got spare time to prepare a reproduction right now, sorry. I'll try to find some time to provide you one next week.

tegola avatar Nov 19 '25 15:11 tegola