I followed this instruction to configure react with tailwind css tailwind docs
Node.js v22.1.0
PS D:vscodemy-project> npx tailwindcss -i ./src/input.css -o ./src/output.css --watch
Specified input file ./src/input.css does not exist.
I have been trying to configure my first React app with Tailwind and I keep getting this error from this point.
1
You can try these steps.
1. Instal Tailwind + autoprefix + postcss:
autoprefix and postcss are some additional tools you may find useful.
npm install tailwindcss postcss autoprefixer
2. Generate Tailwind config files: This will create two files in your project, tailwind.config.js
and postcss.config.js
.
npx tailwindcss init -p
3. Configure Tailwind : paste this in tailwind.config.js
.
module.exports = {
content: [
"./src/**/*.{js,jsx,ts,tsx}",
],
theme: {
extend: {},
},
plugins: [],
};
4. Add Tailwind to Your CSS: open your global css file, src/index.css
(assuming default react app) and add these directives to the top of the file.
@tailwind base;
@tailwind components;
@tailwind utilities;
/*the rest of your css*/
Then restart your app and you should be good to go. Hope this helps.