Install Tailwind CSS Complete Setup Guide 2026
Install Tailwind CSS v4 in your project with our step-by-step installation guides. Whether you use Vite, CDN, PostCSS, or a specific framework like React or Next.js, we cover every setup method with clear, copy-paste-ready commands and configuration examples.
Install Tailwind CSS with Vite (Recommended)
Vite is the recommended build tool for Tailwind CSS v4 projects. The dedicated @tailwindcss/vite plugin provides the fastest development experience with instant hot module replacement.
Step 1: Create a New Vite Project
Scaffold a new project using the Vite CLI. Choose your preferred framework when prompted.
npm create vite@latest my-project -- --template react
cd my-projectStep 2: Install Tailwind CSS and the Vite Plugin
Install Tailwind CSS v4 along with its dedicated Vite plugin as development dependencies.
npm install -D tailwindcss @tailwindcss/viteStep 3: Configure the Vite Plugin
Add the Tailwind CSS plugin to your vite.config.ts configuration file.
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import tailwindcss from '@tailwindcss/vite'
export default defineConfig({
plugins: [
react(),
tailwindcss(),
],
})Step 4: Import Tailwind CSS in Your Stylesheet
Add the Tailwind CSS import to your main CSS file (usually src/index.css).
@import "tailwindcss";Step 5: Start Building
Launch your development server and start using Tailwind CSS utility classes.
npm run dev<h1 class="text-3xl font-bold text-blue-500">
Hello, Tailwind CSS!
</h1>Install Tailwind CSS with PostCSS
If your project uses webpack, Parcel, Rollup, or another build tool with PostCSS support, use the @tailwindcss/postcss plugin.
npm install -D tailwindcss @tailwindcss/postcssCreate or update your postcss.config.mjs file:
export default {
plugins: [
"@tailwindcss/postcss",
],
}Then import Tailwind CSS in your main stylesheet:
@import "tailwindcss";Install Tailwind CSS via CDN
For quick prototyping and experimentation, you can use the Tailwind CSS CDN script without any build step. This method is not recommended for production deployments.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Tailwind CSS CDN Example</title>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body>
<h1 class="text-3xl font-bold text-center mt-10">
Hello Tailwind CSS!
</h1>
</body>
</html>The CDN version cannot tree-shake unused styles and will be significantly larger than a properly built Tailwind CSS bundle. Use it only for prototyping and learning, not production websites.
Installation Method Comparison
Compare the three main approaches to installing Tailwind CSS to choose the best option for your project.
| Feature | Vite Plugin | PostCSS | CDN |
|---|---|---|---|
| Setup Time | ~2 min | ~3 min | ~30 sec |
| Build Performance | ★★★★★ | ★★★★☆ | N/A |
| Tree Shaking | ✓ Yes | ✓ Yes | ✗ No |
| HMR Support | ✓ Instant | ✓ Standard | ✗ Full reload |
| Production Ready | ✓ Yes | ✓ Yes | ✗ No |
| Custom Config | ✓ CSS @theme | ✓ CSS @theme | Limited |
Framework-Specific Tailwind CSS Guides
Choose your framework for detailed, step-by-step Tailwind CSS integration instructions.
Frequently Asked Questions
Common questions about installing and configuring Tailwind CSS.
Ready to start styling? Explore the Tailwind CSS Cheat Sheet for a quick reference of all utility classes, or try the interactive playground to experiment with Tailwind CSS in real-time.