How To Install Tailwind CSS in React. This guide focuses on installing Tailwind CSS in a React project created with Vite (a fast build tool) and TypeScript for type safety. Note that the installation process for Tailwind is identical whether you’re using TypeScript (.tsx files) or plain JavaScript (.jsx files).
We’ll walk through each step with detailed guidance, cover prerequisites, and highlight important considerations for a smooth development experience. By the end, you’ll have a fully functional setup ready for production-grade applications.
Table of Contents
How To Install Tailwind CSS in React Easily

In the world of modern web development, Tailwind CSS has emerged as a powerful utility-first CSS framework that allows developers to build custom designs without leaving their HTML or JSX files.
Unlike traditional CSS frameworks like Bootstrap, Tailwind provides low-level utility classes that you can compose to create unique UIs efficiently. When paired with React, a popular JavaScript library for building user interfaces, Tailwind shines by enabling rapid prototyping and scalable styling.
Below is the guide that will help you learn the process of installing Tailwind CSS in React in depth.
Prerequisites
Before diving in, ensure you have the following:
- Node.js: Version 14 or higher is recommended for compatibility with Vite and Tailwind.
- A Code Editor: Something like VS Code, which has excellent support for React, TypeScript, and Tailwind (install the Tailwind CSS IntelliSense extension for auto-completion).
- Basic Knowledge: Familiarity with React basics, command-line interfaces (CLI), and package managers like npm or pnpm.
- Git (Optional): For version control, especially if you’re cloning repositories or using a starter kit.
If you don’t have Node.js installed, we’ll cover that next.
Installing Node.js and Package Managers
Node.js is essential for running JavaScript on the server-side and managing packages. It comes bundled with npm (Node Package Manager), but you can also use pnpm for faster and more efficient package installations (it uses a content-addressable store to avoid duplicates).
Step 1: Install Node.js
- Download the latest LTS (Long-Term Support) version from the official Node.js website.
- Follow the installer for your OS (Windows, macOS, or Linux).
- Verify installation by opening a terminal and running
node -v
npm -vThis should display the versions (e.g., v20.x.x for Node and v10.x.x for npm).
Step 2: Install pnpm (If You Prefer It Over npm).
pnpm is a great alternative to npm for its speed and disk efficiency. To install it globally:
- Using npm:
npm install -g pnpm- Verify
pnpm -v- If you’re on a fresh Node.js install, this will work seamlessly. Note: Throughout this guide, I’ll provide commands for both npm and pnpm; choose based on your preference.
Setting Up a React Project with Vite and TypeScript
Vite is a modern frontend build tool that offers lightning-fast development servers and optimized builds. It’s the recommended way to scaffold new React projects.
Step 1: Create the Project
Open your terminal and run:
- With npm:
npm create vite@latest my-react-app- With pnpm:
pnpm create vite my-react-appSelect the appropriate technology (JavaScript or TypeScript). For this project, TypeScript has been used, but you can choose based on your requirements.
Step 2: Navigate and Install Dependencies
- Change directory:
cd my-react-app- Install dependencies:
- With npm & With pnpm::
npm install
pnpm installStep 3: Start the Development Server
- Run:
- With npm or With pnpm:
npm run dev
or
pnpm run devOpen http://localhost:5173 in your browser to see the default Vite + React app.
Check out the FlyonUI – A Comprehensive Tailwind Component Library

Also available in the pro version. It includes
Installing Tailwind CSS: Next Step in How To Install Tailwind CSS In React
Installing Tailwind CSS as a Vite plugin is the most seamless way to integrate it with frameworks like Laravel, SvelteKit, React Router, Nuxt, and SolidJS.
Step 1: Create your project
- With npm:
npm create vite@latest my-project //ignore if you already setup vite project- With pnpm:
pnpm create vite@latest my-project //ignore if you already setup vite project cd my-projectStep 2: Install Tailwind CSS
Install tailwindcss and @tailwindcss/vite via npm.
npm install tailwindcss @tailwindcss/viteStep 3: Configure the Vite plugin
Add the @tailwindcss/vite plugin to your Vite configuration.
import { defineConfig } from 'vite'
import tailwindcss from '@tailwindcss/vite'
export default defineConfig({
plugins: [
tailwindcss(),
],
})Step 4: Import Tailwind CSS
Add an @import to your CSS file that imports Tailwind CSS.
@import "tailwindcss";Step 5: Start your build process
Run your build process with npm run dev or whatever command is configured in your package.json file.
npm run devStep 6: Start using Tailwind in your code
Make sure your compiled CSS is included in the <head> (your framework might handle this for you), Then start using Tailwind’s utility classes to style your content.
<div className="bg-white">
<h1 className="text-4xl text-red-500 font-medium">Welcome to React + Tailwind</h1>
</div>All set, now you can use Tailwind utility classes in your project.
Ready-Made Starter Kit
To kickstart your project without going through all these steps, I have a ready-made starter kit repository already set up with React, Vite, TypeScript, and Tailwind CSS (using pnpm for package management). It includes basic configurations, a sample component, and is optimized for quick development.
You can clone it from the GitHub repo and simply run pnpm install and pnpm run dev to get started.
Conclusion
Installing Tailwind CSS in a React project with Vite and TypeScript/JavaScript is a straightforward process that unlocks a world of efficient, customizable styling. By following these steps from setting up your environment to configuring and using Tailwind, you’ll be equipped to build responsive, performant applications with ease.
Remember to leverage Tailwind’s utilities wisely, customize as needed, and always test in production mode. Whether you’re a beginner or seasoned developer, this combination accelerates your workflow and leads to cleaner code.
Happy coding 🚀 start experimenting with Tailwind today and watch your React projects come to life!



