alpha

Gives a coding assistant steps for installing and configuring Tailwind CSS v4 in Vite projects with the official plugin, plus migration tips from older setups.
description: 'Tailwind CSS v4+ installation and configuration for Vite projects using the official @tailwindcss/vite plugin'
applyTo: 'vite.config.ts, vite.config.js, **/.css, **/.tsx, **/.ts, **/.jsx, **/*.js'
Instructions for installing and configuring Tailwind CSS version 4 and above using the official Vite plugin. Tailwind CSS v4 introduces a simplified setup that eliminates the need for PostCSS configuration and tailwind.config.js in most cases.
@theme directiveInstall tailwindcss and the @tailwindcss/vite plugin:
npm install tailwindcss @tailwindcss/vite
Add the @tailwindcss/vite plugin to your Vite configuration file:
// vite.config.ts
import { defineConfig } from 'vite'
import tailwindcss from '@tailwindcss/vite'
export default defineConfig({
plugins: [
tailwindcss(),
],
})
For React projects with Vite:
// vite.config.ts
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import tailwindcss from '@tailwindcss/vite'
export default defineConfig({
plugins: [
react(),
tailwindcss(),
],
})
Add the Tailwind CSS import to your main CSS file (e.g., src/index.css or src/App.css):
@import "tailwindcss";
Ensure your main CSS file is imported in your application entry point:
// src/main.tsx or src/main.ts
import './index.css'
Run the development server to verify installation:
npm run dev
Tailwind v4 uses CSS-first configuration. Do not create a tailwind.config.js file unless you have specific legacy requirements.
// ❌ NOT NEEDED in Tailwind v4
module.exports = {
content: ['./src/**/*.{js,ts,jsx,tsx}'],
theme: {
extend: {},
},
plugins: [],
}
When using the @tailwindcss/vite plugin, PostCSS configuration for Tailwind is not required.
// ❌ NOT NEEDED when using @tailwindcss/vite
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}
The old @tailwind directives are replaced by a single import:
/* ❌ OLD - Do not use in Tailwind v4 */
@tailwind base;
@tailwind components;
@tailwind utilities;
/* ✅ NEW - Use this in Tailwind v4 */
@import "tailwindcss";
Use the @theme directive in your CSS to customize your design tokens:
@import "tailwindcss";
@theme {
--color-primary: #3b82f6;
--color-secondary: #64748b;
--font-sans: 'Inter', system-ui, sans-serif;
--radius-lg: 0.75rem;
}
Define custom utilities directly in CSS:
@import "tailwindcss";
@utility content-auto {
content-visibility: auto;
}
@utility scrollbar-hidden {
scrollbar-width: none;
&::-webkit-scrollbar {
display: none;
}
}
Define custom variants in CSS:
@import "tailwindcss";
@variant hocus (&:hover, &:focus);
@variant group-hocus (:merge(.group):hover &, :merge(.group):focus &);
After installation, verify:
tailwindcss and @tailwindcss/vite are in package.json dependenciesvite.config.ts includes the tailwindcss() plugin@import "tailwindcss";text-blue-500, p-4) render correctlyTest the installation with a simple component:
export function TestComponent() {
return (
<div className="min-h-screen bg-gray-100 flex items-center justify-center">
<h1 className="text-3xl font-bold text-blue-600 underline">
Hello, Tailwind CSS v4!
</h1>
</div>
)
}
@import "tailwindcss"; (not old directives)tailwindcss() pluginrm -rf node_modules/.vite && npm run devIf you see "Cannot find module '@tailwindcss/vite'":
npm install @tailwindcss/vite
If TypeScript cannot find types for the Vite plugin, ensure you have the correct import:
import tailwindcss from '@tailwindcss/vite'
If migrating from Tailwind v3:
tailwind.config.js (move customizations to CSS @theme)postcss.config.js (if only used for Tailwind)npm uninstall postcss autoprefixernpm install tailwindcss @tailwindcss/vite@tailwind directives with @import "tailwindcss";@tailwindcss/vite plugin© GitHub, Inc. · MIT · source · posted by @OpenSourceBuffGuy on promptparty.com


Sea turtle carrying floating film studio island
Draws a giant sea turtle carrying a floating island film studio through a starry sky, where fairies polish rough film strips into golden film.
image-prompt, nano-banana, 3d-render, cartoon, fantasy-world, creatures, animals, whimsical, dreamy, cinematic, dramatic-lighting, vibrant-colors, bokeh, miniature, widescreen, night-scene, illustration, concept-art, surreal, storytelling, clay-3d

Desert buggy escapes drones past industrial outpost
Builds a 15-second desert chase video where a racer in an armored buggy escapes drones past an industrial outpost, using five reference images with set jobs.
video-prompt, hailuo, action, multi-shot, timed-beats, camera-movement, reference-image, character-consistency, negative-prompt, cinematic, sci-fi, cars, landscape, aerial-view, tracking-shot, photorealistic, sound-effects, structured-output, long-form, widescreen, realistic-person

Cozy Pixel Art Farm Island Village
Draws a cozy 16-bit pixel-art farming village across six small islands joined by bridges, with exact counts for buildings, animals and crops.
image-prompt, gpt-image, pixel-art, isometric, game-assets, concept-art, maps, worldbuilding, cozy, vibrant-colors, ocean, landscape, wide-shot, widescreen, game-development, video-games, structured-output, whimsical, summer, high-angle, aerial-view, animals, negative-prompt, cityscape
Loading reviews…
Loading comments…