Tailwind isn't working on React project

Im doing a project using React and Tailwind, and at the moment that im styling a component the only classname that works is bg-red-500, can anyone help me? I tried using any other color like bg-blue-500 and that's not working
Solution:
That's probably part of the problem, try rerunning npx tailwindcss init -p to get the postcss.config.js file
Jump to solution
16 Replies
del.hydraz
del.hydraz2y ago
Are you using Vite as your build tool or NextJS?
glorenzatto
glorenzatto2y ago
vite
del.hydraz
del.hydraz2y ago
Ah ok. Could I see your vite.config.ts file?
glorenzatto
glorenzatto2y ago
it's the default file
del.hydraz
del.hydraz2y ago
Ah that makes sense. I'm guessing you followed this link? https://tailwindcss.com/docs/guides/vite
Install Tailwind CSS with Vite - Tailwind CSS
Setting up Tailwind CSS in a Vite project.
glorenzatto
glorenzatto2y ago
Yes, I installed Vite first and then Tailwind, following this link
del.hydraz
del.hydraz2y ago
I'm not entirely sure what the problem is then. Could you possibly try importing the index.css file into App.tsx?
glorenzatto
glorenzatto2y ago
Yes, I've tried this already, but I renamed the index.css default file to input.css, even the className="flex flex-row" isn't working:
del.hydraz
del.hydraz2y ago
Do you have a postcss.config.js file in your project?
glorenzatto
glorenzatto2y ago
No
Solution
del.hydraz
del.hydraz2y ago
That's probably part of the problem, try rerunning npx tailwindcss init -p to get the postcss.config.js file
glorenzatto
glorenzatto2y ago
Thanks a lot! That worked
del.hydraz
del.hydraz2y ago
Oh beautiful, glad I could help. Just for giggles, could you try renaming input.css back to index.css and removing the import? I think Vite will recognize index.css and apply it automatically Also be sure to mark one of the dm's as the answer for indexing
glorenzatto
glorenzatto2y ago
I've tried to rename the input.css back to index.css, and that's still ok, but i need to have the import at main.tsx, if not, then it doesn't work anymore
glorenzatto
glorenzatto2y ago
Really appreciate your help!
del.hydraz
del.hydraz2y ago
Ah, that's where the import is. Good to know, sorry for misleading lol Yeah happy to!
Want results from more Discord servers?
Add your server