Cannot use tailwind with Nuxt UI
My
nuxt.config.ts
:
Running this gives an error when running bun dev
:
Using nuxt
4.0.1, @nuxtjs/tailwindcss
6.14.0, and @nuxt/ui
3.3.0.
If I just use Nuxt UI, there is no tailwind in my app.27 Replies
Hi @Dog. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
The error you’re seeing is due to a conflict between how Tailwind CSS is integrated in Nuxt 4 and the use of the @nuxtjs/tailwindcss module. With Nuxt UI v3 (and Nuxt 4), Tailwind CSS v4 is expected to be configured via CSS imports, not as a separate Nuxt module.
How to fix:
- Remove the
- Remove
@nuxtjs/tailwindcss
module from your modules
array.
- Instead, create a CSS file (e.g., app/assets/css/main.css
) and import both Tailwind CSS and Nuxt UI in it:
- Then, in your nuxt.config.ts
, add this CSS file to the css
array:
This approach follows the official Nuxt UI and Tailwind v4 integration for Nuxt 4. The @nuxtjs/tailwindcss
module is not needed and will cause conflicts, as Tailwind is now handled via CSS imports and PostCSS, not as a Nuxt module. You do not need to manually add Tailwind as a PostCSS plugin either—Nuxt handles this internally when you use the CSS import method Nuxt UI Installation Guide.
Summary:- Remove
@nuxtjs/tailwindcss
from modules
- Use CSS imports for Tailwind and Nuxt UI
- Add your CSS file to the css
array in nuxt.config.ts
This should resolve the error and allow you to use Tailwind with Nuxt UI in Nuxt 4 Nuxt UI Installation Guide.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@634054240557596672> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
im just using the nuxt cli i dont get why i need to do that but whatever
that fixed it
Are styles working? I suspect not. Easy way to do it is to follow tailwindcss docs
they weren't
but kapa's solution fixed it
i wouldve thought it would just be plug and play instead of having to have a css file
Install Tailwind CSS with Nuxt
Setting up Tailwind CSS in a Nuxt project.
@Dog follow this.
the ai solution fixed it
its fine
There is a issue with nuxt tailwindcss module.
Interesting, what deps are installed? Even though you are using kapas solution, i would say to remove all tailwind deps, and follow tailwindcss. I think you have that module installed. You only need two dev deps, @tailwindcss/vite and tailwindcss.
the tailwind docs dont specify -D
are u sure dev deps?
Yep
Tailwindcss doesnt go to prod (i mean the whole thing, just the utility classes)
It scans your files, adds the used utility classes in your files, then creates a css file with all of them.
done that
do i need the vite plugin since i assume nuxt ui does that?
Yep
Just follow tailwindcss docs
alr
When the tailwindcss module is fixed, change to that (i mean why not)
ye
Both of them should be dev deps
do u also happen to know why my app.config.ts isnt being applied?
Where did you place it?
root
oh does it need to be in /app
It should be in app/app.config.ts
Yep
that makes more sense thanks
don't use the tailwind nuxt plugin, just the follow the installation guide from the tailwindcss docs
there's nothing special about the tailwind plugin
tailwind config viewer.....
Also zero config one command is nicer....
@Dog @Cake Fun fact: you don't need to setup tailwindcss if you are using nuxt ui (the vite plugin). Just follow tailwind docs, skip the @tailwindcss/vite parts. Found this in there source code....?
you do
because just with nuxt ui it didnt work
No i think you misunderstood
1. Install nuxt ui wuth nuxi module add
2. Follow nuxt/ui's installation guide
Which is
Create the app/assets/css/main.css
Paste
@import "tailwindcss";
@import "@nuxt/ui";
Add it to nuxt.config.ts
css: ["@/assets/css/main.css"]
Thats it
Nuxt ui comes with tailwindcss installed, and it also configures @tailwindcss/vite if bundler option in nuxt config is @nuxt/vite-bundler (which is by default) or it uses @tailwindcss/postcss
ah right