If you’ve ever felt overwhelmed writing CSS, struggled to name classes, or spent too much time adjusting spacing until your layout “looks right,” then TailwindCSS might be exactly what you need. In this article, we’ll look at what TailwindCSS is, why it’s so popular, and how to set it up quickly in your project.
TailwindCSS is a utility-first CSS framework. This means instead of writing traditional CSS rules and applying them to classes, Tailwind provides small, reusable utility classes that you can apply directly to your HTML to style your UI.
For example, instead of writing:
.button {background-color: blue;color: white;padding: 10px 16px;border-radius: 8px;}
With Tailwind, you simply write:
<button class="bg-blue-500 text-white px-4 py-2 rounded">Click me</button>
👉 It’s cleaner, faster, and keeps your styling directly where it’s being used.
Forget naming conventions like btn-primary or hero-container.
Tailwind uses descriptive utility classes:
text-centermt-6rounded-lgbg-gray-800You can design any layout or style — without fighting predefined components, like in Bootstrap.
Responsive design is incredibly simple:
<p class="text-sm md:text-lg">This text is small on mobile and larger on desktop.</p>
Instead of maintaining long CSS files that get messy over time, Tailwind keeps styles close to the HTML elements that need them. Much easier to maintain.
Let’s walk through the setup from zero to working Tailwind styles.
If you don’t already have a Vite project, create one using the Vite project generator:
npm create vite@latest my-projectcd my-project
Pick your preferred framework when prompted (React, Svelte, Vue, etc.).
Next, install Tailwind CSS along with its Vite integration package:
npm install tailwindcss @tailwindcss/vite
Open your vite.config.js or vite.config.ts and enable the Tailwind plugin:
import { defineConfig } from 'vite'import tailwindcss from '@tailwindcss/vite'export default defineConfig({plugins: [tailwindcss(),],})
This automatically handles Tailwind’s build pipeline, eliminating the need for a separate PostCSS config.
In your main CSS file (e.g., src/style.css), add:
@import "tailwindcss";
This ensures Tailwind’s utility classes are available throughout your project.
Start your development environment:
npm run dev
Vite will now build Tailwind on the fly as you work.
Make sure your stylesheet is included in your HTML (your framework may handle this automatically depending on structure):
<!doctype html><html><head><meta charset="UTF-8" /><meta name="viewport" content="width=device-width, initial-scale=1.0" /><link href="/src/style.css" rel="stylesheet"></head><body><h1 class="text-3xl font-bold underline">Hello world!</h1></body></html>
If everything is configured correctly, you should see a bold, underlined heading styled by Tailwind.
By the end of this article, you now understand:
| What You Learned | Explanation |
|---|---|
| What TailwindCSS is | A utility-first CSS framework |
| Why it’s faster | No custom class naming and styles stay inline |
| How to install it | Using CDN or npm |
| How to build UI quickly | Using utility classes directly in HTML |