Tailwind CSS is a utility-first CSS framework: instead of writing custom CSS classes, you style elements with small single-purpose classes such as p-4, text-lg and bg-blue-600 directly in your HTML. Tailwind v4 is configured in CSS with @import "tailwindcss"; and the @theme directive, and only the classes you use are generated, keeping the final CSS small.
Note: Frameworks release often — confirm version-specific details in the official docs.
The first time many developers see Tailwind, their reaction is “that is a lot of classes”. A button with eight utility classes looks messy compared with a single .btn. But after building a page or two, many find they move faster: no switching between files, no inventing class names and no CSS that grows forever.
This tutorial gets you set up, explains how to think in utilities and shows how to keep Tailwind projects tidy as they grow.
Install Tailwind with Vite
npm create vite@latest my-site
cd my-site
npm install tailwindcss @tailwindcss/vite
Add the plugin to vite.config.js:

import { defineConfig } from "vite";
import tailwindcss from "@tailwindcss/vite";
export default defineConfig({
plugins: [tailwindcss()],
});
Then import Tailwind in your main CSS file:
@import "tailwindcss";
Core Tailwind CSS utility classes
| Category | Examples |
|---|---|
| Spacing | p-4, px-6, mt-8, gap-4 |
| Typography | text-xl, font-bold, leading-relaxed |
| Colour | bg-blue-600, text-slate-700 |
| Layout | flex, grid, grid-cols-3, items-center |
| Borders and effects | rounded-xl, border, shadow-md |
| States | hover:bg-blue-700, focus-visible:ring-2 |
Example: a card component

<article class="max-w-sm rounded-2xl border border-slate-200 bg-white p-6 shadow-sm">
<h3 class="text-lg font-bold text-slate-900">Starter plan</h3>
<p class="mt-2 text-slate-600">Everything you need to launch a small website.</p>
<a href="/pricing" class="mt-4 inline-block rounded-lg bg-blue-600 px-4 py-2 font-semibold text-white hover:bg-blue-700">
View pricing
</a>
</article>
Responsive design and dark mode
Prefix utilities with breakpoints — sm:, md:, lg:, xl: — which apply at that width and above (mobile-first). Use dark: for dark mode styles.
<div class="grid grid-cols-1 gap-6 md:grid-cols-2 lg:grid-cols-3 dark:bg-slate-900">…</div>
Customising your theme
@import "tailwindcss";
@theme {
--color-brand-600: #1D5FB4;
--font-display: "Plus Jakarta Sans", sans-serif;
}
This creates utilities such as bg-brand-600 and font-display.
Pros and cons
Pros
- Fast to build without naming classes
- Consistent design tokens
- Small production CSS
- Great with component frameworks

Cons
- Long class lists in HTML
- Learning curve for class names
- Needs a build step for most projects
Tip: Install the official Tailwind CSS IntelliSense extension for VS Code to get autocomplete and previews for class names.
Thinking in utilities
Instead of writing a new CSS rule for each component, you combine small, single-purpose classes. A practical approach:
- Start with layout
flex,grid,gap-4,items-center. - Add spacing
p-6,mt-4,space-y-2. - Set typography
text-lg,font-semibold,text-slate-700. - Add decoration
rounded-xl,border,shadow-sm. - Add states and breakpoints
hover:,focus-visible:,md:.
Keeping Tailwind projects maintainable
- Extract repeated patterns into components (React, Vue, Blade or template partials).
- Define brand colours and fonts once with
@theme. - Use the Prettier plugin to sort classes consistently.
- Prefer design tokens over one-off arbitrary values.
- Keep accessibility utilities such as focus rings on every interactive element.
Tip: Rebuild one familiar component — a card or navbar from a site you like — using only Tailwind utilities. It is the fastest way to learn the class names.
Compare frameworks in Bootstrap vs Tailwind, and make sure you know the CSS behind it: flexbox and grid.
Frequently asked questions
Is Tailwind CSS good for beginners?
Yes, if you already know basic CSS. Tailwind classes map closely to CSS properties, so understanding CSS first makes it easier.
Does Tailwind make websites slower?
No. Tailwind only generates the classes you use, so production CSS is usually small.
Can I use Tailwind with WordPress?
Yes. Many custom themes and block themes use Tailwind with a build step.
Do I need JavaScript to use Tailwind?
No. Tailwind is a CSS framework. You need Node.js for the build tooling, but the output is plain CSS.
Can I use Tailwind without a build step?
For quick experiments, Tailwind offers a browser-based option, but production sites should use the build process for performance.
How do I add custom CSS with Tailwind?
Write normal CSS in your stylesheet alongside the Tailwind import, or use arbitrary values in classes for one-off cases.
Is Tailwind good for large teams?
Yes, when paired with shared components and a defined theme. It reduces naming debates and keeps styles consistent.
Further reading: MDN’s web development learning area.







