What Is Tailwind CSS and How Do You Start Building a UI With It?
Updated
Tailwind CSS is a utility-first CSS framework: instead of writing custom CSS rules, you style elements by adding small, single-purpose classes directly in your markup (flex, px-4, text-sm, rounded-lg). You start by installing it through your project's package manager, pointing it at your template files so it can scan them, and then composing layouts from those utility classes. It fits best when you want full control over design without leaving your HTML, and it fits worst when a team needs ready-made, pre-styled widgets out of the box.
What "utility-first" actually means
A traditional stylesheet gives a component a name and describes it once:
.card {
padding: 1rem;
border-radius: 0.5rem;
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
Tailwind skips the naming step and applies the same result inline:
<div class="p-4 rounded-lg shadow">
...
</div>
Each class does one thing. You build complex designs by combining many of them. The trade-off is visible immediately: you stop inventing class names and stop hunting through stylesheets, but the markup gets longer.
How it differs from Bootstrap and similar frameworks
| Dimension | Tailwind CSS | Component frameworks (e.g. Bootstrap) |
|---|---|---|
| Unit of styling | Single-purpose utility classes | Prebuilt components (.btn, .card, .navbar) |
| Default look | None — you design it | Opinionated visual theme |
| Customization | Change values in config, classes follow | Override framework CSS or use its variables |
| Markup length | Longer, many classes per element | Shorter, one or two classes per element |
| Best when | You want a custom design system | You want a working UI fast with a known look |
Neither is strictly better. Utility-first helps when the design is specific and you'd otherwise fight a framework's defaults. It hurts when you need a standard admin panel this afternoon and don't care about the visual identity.
Setting up Tailwind in a project
The exact commands depend on your build tool, but the shape of the process is consistent:
- Install the package. Add Tailwind as a dev dependency via your package manager (npm, pnpm, yarn, or bun).
- Create the config. Generate a config file that declares where your content lives and lets you extend the theme (colors, spacing, fonts).
- Point it at your files. The
content(or equivalent) setting lists the glob patterns for your HTML, JS, and component files. This is the step that matters most — see the pitfalls below. - Add the directives to your CSS. Your main stylesheet imports Tailwind's layers (base, components, utilities).
- Run the build. Tailwind scans the files matched by your content patterns, finds which utility classes appear, and generates only those. The output is a CSS file you link or bundle as usual.
The expected result: a small CSS file containing exactly the classes your markup uses, plus any base styles you opted into.
Verify it worked
Add a class you've never used before, like bg-red-500, to an element and rebuild. If the background turns red, the scan is working. If nothing changes, the file containing that class isn't matched by your content patterns — that's the single most common setup failure.
The core workflow
Once configured, day-to-day work is composition:
- Layout with flex and grid utilities (
flex,grid,gap-4,items-center). - Spacing with the padding and margin scale (
p-6,mt-2,space-y-4). - Responsive design with breakpoint prefixes applied inline:
text-sm md:text-base lg:text-lgmeans small by default, larger from themdbreakpoint up, larger still fromlg. - States with variant prefixes:
hover:bg-blue-600,focus:ring-2,disabled:opacity-50. - Dark mode with a
dark:prefix, if enabled in config.
Because variants stack (md:hover:bg-blue-600), you express responsive and interactive behavior without writing a single media query or pseudo-class rule by hand.
Where to get components and templates instead of writing every class
Writing every class by hand is slow for common patterns. Curated directories collect prebuilt options so you can start from something real:
- Free starter templates to kickstart a project.
- Premium themes and templates — the Windy Toolbox listing shows examples ranging from roughly $19 to $149+, including dashboard templates, landing pages, SaaS sites, and agency portfolios built with Tailwind alongside tools like Astro, React, Vue, Nuxt, and Gatsby. Some entries are marked as affiliate links.
- Pre-designed UI kits for adding components faster. The listing names Flowbite UI (a Figma design kit built for Tailwind integration, by Themesberg) and Preline UI (an open-source set of prebuilt components on the utility-first framework, by Htmlstream).
- Tools and generators for common development tasks.
If you're evaluating a paid template, check which framework version and build tool it targets before buying — a template built for an older Tailwind major version may need migration work.
Common pitfalls
Class-list bloat. A single element can accumulate a dozen or more classes. This is normal, but when the same long list repeats across files, extract it into a component (in React, Vue, etc.) or a reusable partial rather than copy-pasting.
Content configuration mistakes. If a file isn't matched by your content patterns, the classes it uses won't be generated and styles silently disappear. This bites hardest with dynamically constructed class names — Tailwind can't see bg-${color}-500 because the full string never appears in the source. Use complete class names or a safelist instead.
Treating it as a component library. Tailwind gives you no buttons or cards. If you expect drop-in widgets, pair it with a component set like the UI kits above, or you'll spend the first day rebuilding basics.
Skipping the design tokens. Defining your colors, spacing, and fonts in the config once keeps the whole project consistent. Scattering arbitrary values everywhere defeats much of the point.
Deciding whether to use it
Choose Tailwind when you want a custom interface, are comfortable with markup-heavy files, and value not naming CSS classes. Choose a component framework when you need a conventional look quickly and don't want to assemble every element. Either way, starting from a template or UI kit shortens the path from setup to a working screen.