I’ve never used Tailwind and thought I’d give it a try for a new project I’m working on. I quite literally copy/pasted the instructions provided in their docs here: https://tailwindcss.com/docs/guides/vite and none of the styles are being applied.
The only thing I’ve done to change the vite app is remove the default App.css and remove the default styling inside the index.css. However, I correctly updated all the imports so this shouldn’t be causing any issue. Can someone help me diagnose this issue?
package.json:
{
"name": "client",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview"
},
"dependencies": {
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@types/react": "^18.2.66",
"@types/react-dom": "^18.2.22",
"@typescript-eslint/eslint-plugin": "^7.2.0",
"@typescript-eslint/parser": "^7.2.0",
"@vitejs/plugin-react": "^4.2.1",
"autoprefixer": "^10.4.19",
"eslint": "^8.57.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.6",
"postcss": "^8.4.38",
"tailwindcss": "^3.4.3",
"typescript": "^5.2.2",
"vite": "^5.2.0"
}
}
postcss.config.js:
export default {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}
tailwind.config.js:
/** @type {import('tailwindcss').Config} */
export default {
content: ["./index.html", "./src/**/*.{js,ts,jsx,tsx}"],
theme: {
extend: {},
},
plugins: [],
};
index.css:
@tailwind base;
@tailwind components;
@tailwind utilities;
App.tsx:
import "./index.css";
function App() {
return (
<>
<h1 className="text-3xl font-bold underline">Hello world!</h1>
</>
);
}
export default App;