Tailwind CSS classes not applying correctly in Vite + React setup #17838
Unanswered
ZakariaMerghmi
asked this question in
Help
Replies: 1 comment
-
Just wanted to share that I found the solution to my issue. The problem was caused by default CSS applied to the css ✅ Solution: Everything works great now. Best regards, |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi Tailwind team,
I’m working on a Vite + React setup and successfully installed Tailwind CSS. Tailwind classes like bg-red-500 and text-3xl work fine on
<h1>
but they do not apply on<button>
elements.function App() { return ( <div className="bg-red-500"> <h1 className="text-white text-3xl">Hello world</h1> <button className="bg-amber-500 text-white px-4 py-2">Click Me</button> </div> ); }
What I’ve tried:
Tailwind is installed via npm install tailwindcss @tailwindcss/vite.
My vite.config.js includes the plugin correctly.
My index.css includes:
@import "tailwindcss";
I removed all custom CSS (like App.css) to rule out overrides.
Cleared browser and Vite caches, reinstalled node_modules.
Still, the button appears unstyled in the browser. Could this be an issue with Vite, Tailwind, or default browser button styles?
Thanks in advance for your help!
Best regards,
Zakaria
Beta Was this translation helpful? Give feedback.
All reactions