How to setup tailwind in vite react app (2025)


You might be facing issue in setting up tailwind in your vite react app. Well, that is because the latest updates in both, tailwind and vite have changed the way how tailwind is set up in a react app.
Here’s how you have to install tailwind in your react app:
Install react using Vite react (on windows)
$ npm create vite@latest my-project
Then follow the prompts!
Install dependencies
$ cd my-project $ npm install
Install tailwindcss
npm install tailwindcss @tailwindcss/vite
Configure the Vite Plugin
This is one of the most important steps.
In your my-project directory,
Go to vite.config.ts or vite.config.jsPaste this code into that file
import { defineConfig } from 'vite' import react from '@vitejs/plugin-react' import tailwindcss from '@tailwindcss/vite' export default defineConfig({ plugins: [ tailwindcss(), react() ], })
Import Tailwind CSS into the index.css
Go to the src folder inside my-project directory, then open index.css file and paste the following line at the very top of it.
@import "tailwindcss";
Run the project
You’re good to go now. Run your project and your tailwindcss should perfectly be installed.
$ npm run dev
If it doesn’t let me know in the comments or message me on linkedin, I’d definitely help you out.
Cheers!
Subscribe to my newsletter
Read articles from Saad Khaleeq directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Saad Khaleeq
Saad Khaleeq
Creative. Fast Learner. Super Passionate. Highly Enthusiastic.