DEV Community

Lord Potato
Lord Potato

Posted on

5 1 1 1 1

🎯 Tailwind CSS v4 + Vite + React Setup (The Clean Way)

If you're starting with Tailwind CSS v4, you might’ve noticed:
most tutorials and videos are still stuck in the old version. I faced it too—docs didn’t help much, and outdated commands like tailwindcss inithad me completely lost.

So here’s the step-by-step setup that finally worked for me:

✅ Tailwind v4 Setup with React + Vite

  1. Create your Vite + React project:
    npm create vite@latest my-app -- --template react
    cd my-app

  2. Install Tailwind CSS v4 with Vite plugin:
    npm install -D tailwindcss@latest @tailwindcss/vite

  3. Create and edit src/index.css:
    @import "tailwindcss";

  4. Update vite.config.js:

import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import tailwindcss from '@tailwindcss/vite'

export default defineConfig({
  plugins: [react(), tailwindcss()],
});
Enter fullscreen mode Exit fullscreen mode
  1. Make sure main.jsx imports ./index.css

  2. Test it in App.jsx:

function App() {
  return (
    <h1 className="text-4xl font-bold text-blue-600">
      Hello Tailwind v4!
    </h1>
  );
}
Enter fullscreen mode Exit fullscreen mode
  1. Run your dev server: npm run dev

✅ And you’re all set with Tailwind v4 running in your React app using Vite!

😅 Want to Hear the Chaos Behind This?
If you’re curious about how I actually figured this out—confusion, outdated guides, broken commands, Discord help, and even ChatGPT misfires—I wrote a separate blog post on my full struggle story in Medium.

👉 Read: 💻 My Tailwind CSS v4 Setup Struggle

Hope it helps another beginner avoid the same mess I went through! 💙

Runner H image

An AI Agent That Handles Life, Not Just Work

From ordering flowers to booking your dinner — let Runner H turn your ideas into actions. No prompts, no hassle. Just outcomes.

Try Runner H

Top comments (1)

Collapse
 
nayan_anand profile image
Nayan Anand •

Thank You so much Lord Potato. I have been searching and searching after getting nothing from tailwind docs and youtube, and FINALLLLY. You saved more of my TIME.

Scale globally with MongoDB Atlas. Try free.

Scale globally with MongoDB Atlas. Try free.

MongoDB Atlas is the global, multi-cloud database for modern apps trusted by developers and enterprises to build, scale, and run cutting-edge applications, with automated scaling, built-in security, and 125+ cloud regions.

Learn More

👋 Kindness is contagious

Sign in to DEV to enjoy its full potential.

Unlock a customized interface with dark mode, personal reading preferences, and more.

Okay