Tailwind color issue
I used npm install tailwindcss @tailwindcss/vite which is what tailwind said, installed npm install --save-dev @nuxtjs/tailwindcss according to Nuxt's site, and most styling works, but some button styles and all coloring doesn't work
My files:
11 Replies
Hi @Andiesgames. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
It looks like your Tailwind setup in Nuxt is mostly correct, but there are a few things to check and clarify based on the knowledge sources:
1. Module Installation:
You only need to use one method to add Tailwind to your Nuxt project. The recommended way for Nuxt is to use the
See: Nuxt external configuration files 2. Configuration File:
Your
Your
Your custom colors and fonts are correctly added under
Your
If some button styles and coloring are not working: - Make sure you are using the correct Tailwind classes in your components (e.g.,
Sometimes, changes to Tailwind config require a full restart of the dev server. Stop the server, clear
- Remove the manual
PrimeVue + Tailwind issue ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
You only need to use one method to add Tailwind to your Nuxt project. The recommended way for Nuxt is to use the
@nuxtjs/tailwindcss module. You do not need to manually install and configure @tailwindcss/vite in your vite.plugins array when using the Nuxt module. The Nuxt module handles the integration for you, and adding both can cause conflicts or unexpected behavior.See: Nuxt external configuration files 2. Configuration File:
Your
nuxt.config.js should look like this (no need to import or use @tailwindcss/vite):
You can remove the vite: { plugins: [tailwindcss()] } section.
3. Tailwind Content Paths:Your
tailwind.config.js content array looks good and should pick up all your Vue and JS/TS files.
4. Custom Colors and Fonts:Your custom colors and fonts are correctly added under
theme.extend. This is the right way to add them in Tailwind v3 and v4.
5. CSS Import:Your
assets/css/main.css should only need:
If you use Nuxt UI or other libraries, you might also need to import them here, but for plain Tailwind, this is correct.
6. Button Styles and Coloring Not Working:If some button styles and coloring are not working: - Make sure you are using the correct Tailwind classes in your components (e.g.,
bg-customBlue, text-lightText, etc.).
- If you are using a UI library (like Nuxt UI or PrimeVue), check if their styles are conflicting with Tailwind or if you need to adjust the CSS layer order (see PrimeVue + Tailwind issue).
- If you are using Nuxt UI, ensure you import it in your CSS and add the module as shown in the docs.
7. Rebuild and Clear Cache:Sometimes, changes to Tailwind config require a full restart of the dev server. Stop the server, clear
.nuxt and node_modules/.cache, and restart.
Summary:- Remove the manual
@tailwindcss/vite plugin from your Nuxt config.
- Use only the @nuxtjs/tailwindcss module.
- Ensure your Tailwind classes match your custom color and font names.
- Restart your dev server after changes.
If you follow these steps and still have issues, check for conflicting CSS from other libraries or incorrect class names. The knowledge sources do not mention any additional required steps for your described setup beyond these best practices.
Nuxt external configuration filesPrimeVue + Tailwind issue ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
<@548834388100775946> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
It didnt' work. it just keeps breaking. As far as I'm aware, my tailwind is fine. It works in a plain vue project, but not in the nuxt version
Also I installed nuxt tailwind using the official guide, via npm as package manager. My tailwind config looks fine, same for my nuxt config but yeah
Steps to reproduce: create a plain nuxt project, add nuxt tailwind, copy my tailwind config and nuxt config and test it on any component with a custom tailwind color in it
@Andiesgames are you using Nuxt UI 3?
No, is that mandatory?
No it's not, was just check as there were some large breaking changes
@Andiesgames Are you able to share the tailwind code you're using for buttons/ where it's not working?
This is the full vue template from the working version
So what isn't working for you?
all text is just black, no custom colors on it
@Andiesgames don't use the tailwind module
check in the tailwind docs how to install with nuxt, u shouldn't need the module.
tailwind.config.ts is for tailwind v3
in v4 u don't need it
u're mixing both v3 and v4, and both tailwind and the tailwind nuxt module
remove tailwind.config.js and the nuxt module, and check tailwind docs how to do your theme, it should be in the css file where u have
Okay, thank you!