Kritim Yantra
Jun 22, 2025
So you’ve learned React. You’re building projects.
But your UI still looks... well, not so pretty?
What if you could design modern, responsive layouts without writing a single custom CSS file?
That’s where Tailwind CSS comes in—a utility-first CSS framework that’s become a game-changer for front-end developers in 2025.
Let’s explore how to use Tailwind CSS with React, and why it’s the best combo for building stunning UIs—fast.
Tailwind is a CSS framework that gives you ready-to-use utility classes to style directly in your HTML or JSX.
Instead of writing custom CSS, you add class names like
bg-blue-500
ortext-center
to style elements.
Analogy: Tailwind is like LEGO blocks. You get small, powerful pieces to assemble beautiful UIs quickly.
npm create vite@latest my-react-app --template react
cd my-react-app
npm install
npm install -D tailwindcss postcss autoprefixer
npx tailwindcss init -p
tailwind.config.js
:/** @type {import('tailwindcss').Config} */
export default {
content: ["./index.html", "./src/**/*.{js,ts,jsx,tsx}"],
theme: {
extend: {},
},
plugins: [],
};
src/index.css
:@tailwind base;
@tailwind components;
@tailwind utilities;
index.css
in main.jsx
:import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import App from './App';
ReactDOM.createRoot(document.getElementById('root')).render(
<React.StrictMode>
<App />
</React.StrictMode>
);
That’s it—you’re ready to build with Tailwind in React!
function ProfileCard() {
return (
<div className="max-w-sm mx-auto bg-white shadow-lg rounded-xl p-6 text-center">
<img
className="w-24 h-24 mx-auto rounded-full"
src="https://i.pravatar.cc/150?img=32"
alt="User"
/>
<h2 className="text-xl font-bold mt-4">Ajay Yadav</h2>
<p className="text-gray-600">Full Stack Developer</p>
<button className="mt-4 px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700">
Follow
</button>
</div>
);
}
A clean, centered card with rounded edges, hover effects, and fully responsive.
Use sm:
, md:
, lg:
prefixes:
<p className="text-sm md:text-lg">Responsive Text</p>
Easily add dark mode:
// tailwind.config.js
darkMode: 'class',
Then toggle like:
<div className="dark:bg-black dark:text-white">
Use React components + Tailwind utility classes to build:
Use tools like Tailwind UI or DaisyUI for prebuilt components.
Button
, Card
) to reuse styles.classnames
package to conditionally apply classes in JSX.Example:
import clsx from 'clsx';
<button className={clsx('btn', isActive && 'bg-blue-600')}>Click</button>
All with zero CSS files. Just JSX and classNames.
Topic | Why It’s Awesome |
---|---|
⚛️ React | Logic, Components, Hooks |
🎨 Tailwind | Fast styling, Responsive design |
🤝 Together | Perfect combo for fast UI development |
"In 2025, the smartest React developers aren't writing CSS—they’re using Tailwind."
So don’t get stuck writing 100 lines of custom CSS.
Learn Tailwind, combine it with React, and build stunning UIs faster than ever.
🔐 React Authentication with Firebase in 2025 – Easy Login & Signup System
No comments yet. Be the first to comment!
Please log in to post a comment:
Sign in with Google