Setup Tailwind CSS v3 With React
Easy setup with create-react-app

I'm a full stack developer based in Australia. I write articles about Node.js, React, JavaScript & Web Development to make your learning journey easier ๐
Search for a command to run...
Easy setup with create-react-app

I'm a full stack developer based in Australia. I write articles about Node.js, React, JavaScript & Web Development to make your learning journey easier ๐
No comments yet. Be the first to comment.
Introduction Website performance is an important aspect of web development. It consists of mainly two things: The speed of your website How usable is your website for visitors? Importance of website performance Website performance is very importa...

There are plenty of native web APIs that have a variety of uses. Here are 5 useful APIs that I use quite often in my web development projects. Clipboard API The clipboard API is a simple method to copy text to a user's clipboard. This can be used in ...

Hey All ๐ In this article, we'll be covering the Fetch API in JavaScript how you can use it to make HTTP requests. What is the Fetch API? The fetch() method provides a simple way to make HTTP requests in JavaScript. It is natively in the browser, me...

Hey All ๐ In this article, we'll be covering 4 mistakes commonly made by people while learning to code that will seriously impact their coding journey. #1 - Copying and Pasting The first mistake I'll talk about is copying and pasting. We've all don...

Introduction There are plenty of units in CSS. From px to vh, there is an abundance of units all with their distinctive use cases. Considering the amount of options, its perfectly reasonably to be confused as to which unit you should use and where. T...

In this article, I'll be showing you how to setup Tailwind CSS v3 with React so you start building great UIs in React with Tailwind's utility classes.
First, lets create a new react app using create-react-app:
npx create-react-app app-name
Then change into its directory:
cd app-name
Replacing app-name with the name of your application
Next, we can install Tailwind CSS and its peer dependencies as dev dependenciees:
npm install -D tailwindcss postcss autoprefixer
After installing the dependencies, we can run the init command to generate a tailwind.config.js file:
npx tailwindcss init -p
Next, we need to update the content property in the tailwind.config.js file:
// tailwind.config.js
module.exports = {
content: [
"./src/**/*.{js,jsx,ts,tsx}",
],
theme: {
extend: {},
},
plugins: [],
}
Lastly, we need to add the following @tailwind directives to the index.css file in the src directory:
/* src/index.css */
@tailwind base;
@tailwind components;
@tailwind utilities;
We can now run the react app with npm start and everything should be working. You can now start using Tailwind CSS in your project.

In this article, you have learned how to setup Tailwind CSS with a create-react-app project. I hope this guide has helped you and have a great day!
๐ Thanks for reading this article!
If you like what I do and would love to see more related content, subscribe to my newsletter and follow me on my other social platforms:
GitHub: Blake-K-Yeboah
LinkedIn: Blake Yeboah
Twitter: Blake Yeboah
You can also show your support by buying me a coffee ๐