Tailwind CSS v4 · CSS-first config · utilities · variants · @theme · verified 2026

Tailwind CSS cheat sheet

Style with utility classes straight in your markup — flex items-center gap-4 p-6 rounded-lg instead of a separate stylesheet. Tailwind v4 is a ground-up rewrite: CSS-first config (no more tailwind.config.js for most projects), one @import "tailwindcss";, automatic content detection, and a design system exposed as native CSS variables. This sheet covers install, the core utility vocabulary, responsive & state variants, container queries, and customizing via @theme / @utility.

setup & config core utilities responsive & state customization directives & migration gotcha most common

Verified 2026-08-31 against the Tailwind CSS v4 docs (tailwindcss.com). v4 targets modern browsers (Safari 16.4+, Chrome 111+, Firefox 128+) and uses OKLCH colors, cascade layers, and @property. ⚠️ v3 code differs a lot — the @tailwind directives & JS config are v3; see the migration card.

Outline

Import Tailwind, learn the utility grammar (layout → spacing → type/color), stack responsive & state prefixes, then extend the system in CSS with @theme and @utility.

Setup & core

  1. 1Install & import
  2. 2@theme config
  3. 3Layout: flex & grid
  4. 4Spacing & sizing

Utilities & variants

  1. 5Typography & color
  2. 6Responsive breakpoints
  3. 7State & dark variants
  4. 8Container queries

Customization

  1. 9Arbitrary values & @apply
  2. 10Custom utilities & variants
  3. 11Directives & functions
  4. 12v3 → v4 migration

Setup & Core

Install, configure in CSS, and lay out the page.

1Install & importv4 setup
2@theme configCSS-first
3Layout: flex & gridstructure
4Spacing & sizingthe scale

Utilities & Variants

Type, color, and the prefixes that make utilities conditional.

5Typography & colorlook & feel
6Responsive breakpointsmobile-first
7State & dark variantsconditional styling
8Container queriesbuilt-in in v4

Customization & Reference

Escape hatches, custom utilities, and the directive/function reference.

9Arbitrary values & @applyone-offs
10Custom utilities & variants@utility · @variant
11Directives & functionsthe @-rules
12v3 → v4 migrationwhat changed

Worth memorizing

@import "tailwindcss";one line replaces v3's 3 directives
@tailwindcss/viterecommended install; no content array
@theme { --color-* }CSS-first config → auto utilities
flex items-center justify-between gap-4layout core
p-4 = 0.25rem × none --spacing token drives the scale
bg-blue-500/50color + /NN opacity (color-mix)
md: = that width AND UPmobile-first; base = unprefixed
hover: focus: dark: group-hover:state variants stack
@container + @md:container queries, built in
top-[117px]arbitrary values in brackets
@utility / @custom-variantextend the system in CSS
no dynamic class namesscanner needs complete literals