How to install and use Tailwind CSS in React.js app
If you are looking to create a stylish and responsive user interface for your React.js app, then Tailwind CSS is the perfect choice for you. In this article, we will walk you through the process of installing and using Tailwind CSS in your React.js app.
Step 1: Install Tailwind CSS
The first step is to install Tailwind CSS in your React.js app. You can do this by running the following command in your terminal:
npm install tailwindcss
Step 2: Configure Tailwind CSS
After installing Tailwind CSS, you need to configure it in your project. Create a new file called tailwind.config.js in the root of your project and add the following code:
module.exports = {
purge: [],
darkMode: false, // or 'media' or 'class'
theme: {
extend: {},
},
variants: {
extend: {},
},
plugins: [],
}
Step 3: Import Tailwind CSS
Now you can import Tailwind CSS in your React.js app. Open your main CSS file (e.g. App.css) and add the following line at the top:
@import 'tailwindcss/base';
@import 'tailwindcss/components';
@import 'tailwindcss/utilities';
Step 4: Use Tailwind CSS classes
Once you have installed and configured Tailwind CSS, you can start using its classes in your React components. For example, you can use the following classes to style your elements:
Hello, World!
Step 5: Build your project
Finally, build your React app to see the changes. Run the following command in your terminal:
npm run build
Congratulations! You have successfully installed and used Tailwind CSS in your React.js app. Now you can create beautiful and responsive designs with ease.
I followed the same but its not working underline is not showing
Thanks for the info
Why does the indes.css giving error on the @taiwind base, componets and utlities; that was pasted above in that file?
Thank you so much 😊
for some reason Tailwind v 3.3.3 is not working npx tailwindcss -i ./src/input.css -o ./dist/output.css –watch
tailwind not working when I implement any style
Thank you very much! I was so frustrated, didnt know how to connect tailwindcss to react! I subscribed to ur channel!!!
can anything be done about the errors in the index.css file?
what about the postcss issue
thank u
good and work alsoooo sir