Setup Tailwind CSS in React
0
In this post we will see how to install tailwind.css in react
Installation
- Install tailwind with the below command
- Create a PostCSS configuration file in your root directory manually or you can use the command:
- paste the below code in the config file
- Create 2 .css files in
src/assets/
name them astailwind.css
andmain.css
- Add below code to
tailwind.css
file
- Go to
package.json
and change thescripts
as below
- Go to
index.js
and import themain.css
and deleteindex.css
import
That's it. whenever you run the build or start comand the tailwind css will be compiled and added to main.css
file. Now you can use tailwind.css.