- How to install TailwindCSS in ReactJS+Vite
- Install dependencies
npm i -D tailwindcss postcss autoprefixer
- Run npx command
- Configure the tailwind.config.ts file
/** @type {import('tailwindcss').Config} */
export default {
content: ['./index.html', './src/**/*.{js,ts,jsx,tsx}'],
theme: {
extend: {},
},
plugins: [],
};
- Add the Tailwind directives to
src/index.css
file
@tailwind base;
@tailwind components;
@tailwind utilities;
/** @type {import('tailwindcss').Config} */
export default {
content: ['./index.html', './src/**/*.{vue,js,jsx,ts,tsx}'], // Para Vue, Si es React omitir ese
theme: {
extend: {},
},
plugins: [],
};