I too struggled initially setting up Tailwind/Postcss initially, then I configured these steps combining documentations, all youtube tutorials. This will surely work, just go stepwise
Using the new Tailwind CSS Version 4+ Latest supports auto configurations. (learn more about it from documentations).
We don’t have tailwind.config.js and postcss.config.js anymore.
Start a fresh new App
Note: Ensure using
Command Prompt CMDTerminal and notPowershell pslorGit Bashor others, inside your code editor.I face no errors when doing this
npm create vite@latest my-app -- --template <template_name>
Eg. For React:
npm create vite@latest my-app -- --template react
cd my-app
code -r my-app
Opens the app in another VS Code window.
npm install tailwindcss @tailwindcss/vite
Confirm the installation via package.json
"dependencies": {
"@tailwindcss/vite": "^4.1.11",
"react": "^19.1.0",
"react-dom": "^19.1.0",
"tailwindcss": "^4.1.11"
}
(With PostCss)
npm install -D @tailwindcss/postcss
and
npm install tailwindcss @tailwindcss/vite
Confirm the installation via package.json
"devDependencies": {
"@eslint/js": "^9.35.0",
"@tailwindcss/postcss": "^4.1.13",
"@types/react": "^19.1.13",
"@types/react-dom": "^19.1.9",
"@vitejs/plugin-react": "^5.0.2",
"eslint": "^9.35.0",
"eslint-plugin-react-hooks": "^5.2.0",
"eslint-plugin-react-refresh": "^0.4.20",
"globals": "^16.4.0",
"vite": "^7.1.6"
}
vite.config.jsimport { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import tailwindcss from '@tailwindcss/vite' //1. Line 1
// https://vite.dev/config/
export default defineConfig({
plugins: [
tailwindcss(), //2. Line 2
react()
],
})
And press CTRL + S to save.
project/src/index.css
@import "tailwindcss";
:root {
font-family: system-ui, Avenir, Helvetica, Arial, sans-serif;
.
.
remove this default css..
}
rfc
export default function App() {
return (
<h1 className='text-lg font-bold underline text-red-500'>
YB-Tutorials
</h1>
)
}
npm run dev
Visit http://localhost:5173/
Done...!