AI Workshop: learn to build apps with AI →
Tailwind CSS: Setting up Tailwind CSS on Vite

Join the AI Workshop and learn to build real-world apps with AI. A hands-on, practical program to level up your skills.


I assume you created a Vite app, perhaps a React app using

npm create vite@latest the-app-name

# or

bun create vite the-app-name

Let’s add Tailwind CSS to style our application.

Install Tailwind CSS and its Vite plugin:

npm install tailwindcss @tailwindcss/vite

# or 

bun add tailwindcss @tailwindcss/vite

Add the @tailwindcss/vite plugin to your Vite configuration in vite.config.ts:

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

// https://vite.dev/config/
export default defineConfig({
  plugins: [
    react(), 
    tailwindcss()
  ],
})

Add this at the top of src/index.css to use the new import syntax:

@import "tailwindcss";

Tailwind v4 auto-detects your content, so you don’t need a tailwind.config.* file unless you want to customize the theme or add plugins.

Now Tailwind CSS is ready to use in our project.

You’ll see the layout is now a bit off, that’s a sign that Tailwind is configured, because it’s adding preflight styles:

Lessons in this unit:

0: Introduction
1: Box model properties
2: Colors
3: Typography
4: Flexbox and Grid in Tailwind
5: Modifiers
6: Responsive design in Tailwind
7: Apply a style to children with Tailwind
8: How to fix Unknown at rule @tailwindcss (unknownAtRules) in VS Code
9: How to align center vertically using Tailwind
10: How to use custom fonts with Tailwind CSS
11: ▶︎ Setting up Tailwind CSS on Vite
12: Show-hide an element based on existence of a parent class in Tailwind
13: The Tailwind Cheat Sheet
14: How to set up Tailwind CSS (v4)
15: You can’t generate classes dynamically in Tailwind