# Tailwind CSS

> Utility-first styling that keeps design decisions consistent and colocated with markup; our recommended default for new projects. Free notes, key concepts,...

Canonical: https://www.internhack.in/roadmaps/tracks/frontend/tailwind
Last updated: 2026-11-28

Utility-first styling that keeps design decisions consistent and colocated with markup; our recommended default for new projects.

Beginner · about 6 hours · difficulty 2/5

Learn first: [Custom Properties and Modern CSS Features](https://www.internhack.in/roadmaps/tracks/frontend/modern-css), [Build Tools and Bundlers](https://www.internhack.in/roadmaps/tracks/frontend/build-tools)

Plain CSS works, but in a large app you fight naming, dead styles nobody dares delete, and specificity battles. Tailwind solves this by giving you small, single-purpose classes (`flex`, `gap-4`, `text-sm`, `md:grid-cols-3`) that you compose directly in markup. The build step scans your files and emits only the classes you actually used.

### Why it is our default

- **Consistency**: spacing, colours and font sizes come from a shared scale, so you stop inventing `margin: 13px`.
- **Locality**: the styles for a component live in the component. Deleting the component deletes its styles.
- **Speed**: no context switching between files, and responsive or state variants are just prefixes: `hover:`, `focus-visible:`, `dark:`, `md:`.
- **Ecosystem**: shadcn/ui, many templates and most modern React tooling assume it.

### How to use it well

- Configure your **theme** (colours, fonts, radii) with CSS variables so the design system lives in one place.
- Extract **components**, not `@apply` soup. If a button's class list repeats, make a `Button` component.
- Use a class-merging helper (`clsx` plus `tailwind-merge`) for conditional classes and overrides.
- Install the editor extension for autocomplete and class sorting.

### Pitfalls

- Tailwind is still CSS. If you do not understand flexbox, grid and the box model, utilities will not save you.
- Never build class names dynamically (`"bg-" + color`); the scanner cannot see them. Map values to full class strings.
- Long class lists are fine, but readable ordering and extraction into components matter.

### Good enough to move on

You can build a responsive, dark-mode-aware card grid and navbar using only utilities, customise the theme colours, and explain why dynamic class strings break.

## Key concepts

- **Utility-first mindset**
- **Responsive and state variants**
- **Theme configuration with CSS variables**
- **Dark mode**
- **Conditional classes with clsx and tailwind-merge**
- **Extracting components vs @apply**
- **Arbitrary values and plugins**

## Other options for this step

- [CSS Modules](https://www.internhack.in/roadmaps/tracks/frontend/css-modules): Write normal CSS files whose class names are scoped to one component automatically, with zero runtime cost.
- [Sass and Preprocessors](https://www.internhack.in/roadmaps/tracks/frontend/sass): Variables, nesting, mixins and partials compiled to CSS; still common in existing codebases even though native CSS has caught up.
- [CSS-in-JS](https://www.internhack.in/roadmaps/tracks/frontend/css-in-js): Style components with JavaScript (styled-components, Emotion) or zero-runtime tools (vanilla-extract, Panda); know the trade-offs.

## Mini project

Rebuild one of your earlier HTML/CSS pages with Tailwind: responsive navigation, a card grid and a pricing table, with a working dark mode toggle driven by a class on the html element.

## Check yourself

Why does writing className={\`text-${size}\`} fail in production, and how do you fix it?

## Free resources

- [Tailwind CSS Documentation](https://tailwindcss.com/docs) (Tailwind CSS)
- [Styling with utility classes](https://tailwindcss.com/docs/styling-with-utility-classes) (Tailwind CSS)

Previous: [Linting and Formatting](https://www.internhack.in/roadmaps/tracks/frontend/linting-formatting) · Next: [CSS Modules](https://www.internhack.in/roadmaps/tracks/frontend/css-modules)

## More in Styling at Scale

- [Tailwind CSS](https://www.internhack.in/roadmaps/tracks/frontend/tailwind)
- [CSS Modules](https://www.internhack.in/roadmaps/tracks/frontend/css-modules)
- [Sass and Preprocessors](https://www.internhack.in/roadmaps/tracks/frontend/sass)
- [CSS-in-JS](https://www.internhack.in/roadmaps/tracks/frontend/css-in-js)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [Frontend Developer Roadmap](https://www.internhack.in/roadmaps/tracks/frontend)
