Setup Tailwindcss in Create React App

npm install tailwindcss postcss postcss-cli autoprefixer@^9.8.6

npx tailwindcss init — full

create folder style in src

add file main.css and tailwind.css

in tailwind.css add this code
@tailwind base;
@tailwind components;
@tailwind utilities;

//create file postcss.config.js to root add this code in it
const tailwinds = require(‘tailwindcss’)

module.exports = {
plugins: [ tailwinds(‘./tailwind.config.js’), require(‘autoprefixer’) ]

}

add this code to package json scripts
“build:css”: “postcss src/style/tailwind.css -o src/style/main.css”,
“build:watch”: “postcss src/style/tailwind.css -o src/style/main.css — watch”

npm run build:css

add this code to index.js

import ‘./style/main.css’;

--

--