Tailwind CSS with Vite Complete Setup Guide 2026
Tailwind CSS and Vite are the perfect combination for modern frontend development. This guide walks you through setting up Tailwind CSS v4 with Vite using the official @tailwindcss/vite plugin, covering React, Vue, and Vanilla JavaScript project configurations.
How to install Tailwind CSS with Vite: Run npm install -D tailwindcss @tailwindcss/vite, add the tailwindcss() plugin to your vite.config.ts, then add @import "tailwindcss" to your main CSS file. That's it no config file needed with Tailwind CSS v4.
React + Vite + Tailwind CSS Setup
The most popular combination. Create a React project with Vite and add Tailwind CSS v4 in under 2 minutes.
1. Create the React + Vite project
npm create vite@latest my-app -- --template react-ts
cd my-app
npm install2. Install Tailwind CSS
npm install -D tailwindcss @tailwindcss/vite3. Add the Vite plugin
// vite.config.ts
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import tailwindcss from '@tailwindcss/vite'
export default defineConfig({
plugins: [
react(),
tailwindcss(),
],
})4. Import Tailwind CSS
/* src/index.css */
@import "tailwindcss";5. Start building
npm run dev// src/App.tsx
export default function App() {
return (
<div className="min-h-screen bg-gray-950 flex items-center justify-center">
<h1 className="text-4xl font-bold text-cyan-400">
Tailwind CSS + Vite + React ⚡
</h1>
</div>
)
}Vue + Vite + Tailwind CSS Setup
Vue developers can use the same @tailwindcss/vite plugin with identical configuration.
npm create vite@latest my-vue-app -- --template vue-ts
cd my-vue-app
npm install
npm install -D tailwindcss @tailwindcss/viteThe vite.config.ts setup is the same just swap @vitejs/plugin-react with @vitejs/plugin-vue.
Custom Theme Configuration
Tailwind CSS v4 uses CSS-first configuration. Customize your design tokens directly in your stylesheet.
@import "tailwindcss";
@theme {
--color-brand: #06b6d4;
--color-brand-dark: #0891b2;
--font-display: 'Inter', sans-serif;
--breakpoint-3xl: 1920px;
}These custom values are automatically available as utility classes: bg-brand, text-brand-dark, font-display, and 3xl: responsive prefix.
Vite Plugin vs PostCSS: Which Should You Choose?
| Feature | @tailwindcss/vite | @tailwindcss/postcss |
|---|---|---|
| Setup Complexity | Simple (1 plugin) | Moderate (PostCSS config) |
| HMR Speed | Near-instant | Fast |
| Build Performance | Optimized for Vite | Standard PostCSS |
| Framework Support | Vite-based only | Any build tool |
| Recommended For | New Vite projects | Existing PostCSS pipelines |
Frequently Asked Questions
Next steps: explore the Tailwind CSS Cheat Sheet for a quick class reference, or learn Tailwind CSS with React for advanced integration patterns.