Tailwind CSS Handbook v4.3

Cheat Sheet

Every Tailwind v4 utility family on one scannable page — layout, flexbox, grid, spacing, typography, colour, effects, transforms, variants and breakpoints.

A lookup table, not a tutorial. Each section links to the page that explains the why.

Reading a class name#

TEXT
md:hover:bg-indigo-600/75
▲  ▲     ▲  ▲          ▲
│  │     │  │          └─ opacity modifier — 75% alpha
│  │     │  └──────────── value — the --color-indigo-600 token
│  │     └─────────────── property — background-color
│  └───────────────────── state variant — :hover
└──────────────────────── responsive variant — @media (width >= 48rem)
SyntaxMeansExample
variant:Condition, stacked left to rightdark:md:hover:underline
- prefixNegative value-mt-4, -rotate-3
/nOpacity modifierbg-black/50, text-white/75
[…]Arbitrary valuetop-[117px], grid-cols-[1fr_auto]
(…)CSS variable shorthand for [var(…)]bg-(--brand)
_A space inside an arbitrary valueshadow-[0_2px_4px_black]
/nameNamed group or peergroup-hover/row:opacity-100
Loading preview…

Layout#

ClassCSS / Effect
block inline-block inlinedisplay: block / inline-block / inline
flex inline-flex grid inline-gridFlex and grid containers
table table-cell table-rowTable display values
flow-root contents list-itemNew BFC / no box / list item
hiddendisplay: none
static relative absolute fixed stickyposition
inset-0 inset-x-4 inset-y-2inset shorthand
top-0 right-4 bottom-full left-1/2Physical offsets
start-0 end-0Logical offsets, flip in RTL
z-0 z-10 z-20 z-30 z-40 z-50 -z-10 z-autoz-index
isolate isolation-autoCreate / clear a stacking context
overflow-auto -hidden -clip -visible -scrolloverflow, plus overflow-x-* and overflow-y-*
overscroll-contain overscroll-none overscroll-autooverscroll-behavior
scrollbar-thin scrollbar-none scrollbar-gutter-stableScrollbars v4.3
containerwidth: 100% capped at each breakpoint
columns-2 columns-3xs break-inside-avoidMulti-column text
object-cover object-contain object-centerReplaced element fit and position
box-border box-contentbox-sizing
float-left float-end clear-bothFloats

Flexbox#

ClassCSS / Effect
flex-row flex-row-reverse flex-col flex-col-reverseflex-direction
flex-wrap flex-wrap-reverse flex-nowrapflex-wrap
flex-1 flex-auto flex-initial flex-noneflex shorthand
grow grow-0 shrink shrink-0flex-grow / flex-shrink
basis-0 basis-1/3 basis-full basis-autoflex-basis
items-start items-center items-end items-baseline items-stretchalign-items
justify-start -center -end -between -around -evenlyjustify-content
content-start content-center content-betweenalign-content
self-auto self-start self-center self-end self-stretchalign-self
items-center-safe justify-center-safeSafe alignment — never overflow the start edge v4.1
order-1 order-first order-last order-noneorder
place-items-center place-content-between place-self-endShorthands for both axes

Grid#

ClassCSS / Effect
grid-cols-3 grid-cols-none grid-cols-subgridgrid-template-columns
grid-rows-4 grid-rows-subgridgrid-template-rows
grid-cols-[repeat(auto-fit,minmax(12rem,1fr))]Responsive tracks with no breakpoints
col-span-2 col-span-fullgrid-column: span 2
col-start-1 col-end-3 row-start-2 row-end-4Explicit placement
row-span-2 row-span-fullgrid-row
grid-flow-row grid-flow-col grid-flow-row-densegrid-auto-flow
auto-cols-fr auto-rows-min auto-rows-maxImplicit track sizing
gap-4 gap-x-6 gap-y-2gap — works in flex too

Spacing#

ClassCSS / Effect
p-4 px-6 py-2 pt-1 pr-3 pb-8 pl-0padding — calc(var(--spacing) * n)
ps-4 pe-4Logical inline padding, flips in RTL
m-4 mx-auto my-8 mt-2 -mt-2margin, negative with a leading -
ms-4 me-4 mbs-4 mbe-4Logical margins v4.2
space-x-4 space-y-2 space-x-reverseMargin between children via :not(:last-child)
gap-4 gap-x-2 gap-y-6Gutters in flex and grid — prefer over space-*
divide-y divide-x-2 divide-gray-200Borders between children
indent-8text-indent

The scale is 0.25rem per step: p-1 = 4px, p-4 = 16px, p-8 = 32px. Any integer works — p-13, mt-96 need no configuration.

Sizing#

ClassCSS / Effect
w-4 w-1/2 w-full w-screen w-autowidth
w-min w-max w-fitIntrinsic widths
w-dvw w-svw w-lvwDynamic, small and large viewport width
h-10 h-full h-screen h-dvh h-svh h-lvhheight
size-10 size-fullwidth and height in one class
min-w-0 min-w-full min-h-0 min-h-screenMinimums — min-w-0 unlocks flex truncation
max-w-md max-w-full max-w-none max-h-96Maximums
max-w-3xs … max-w-7xlThe --container-* scale, 16rem → 80rem
aspect-square aspect-video aspect-3/2 aspect-autoaspect-ratio
basis-1/3flex-basis — sizing along the main axis

Typography#

ClassCSS / Effect
font-sans font-serif font-monofont-family
text-xs text-sm text-base text-lg … text-9xlfont-size plus a paired line-height
text-sm/6 text-base/7Font size with an explicit line height
font-thin font-light font-normal font-medium font-semibold font-bold font-blackfont-weight 100–900
leading-none leading-tight leading-normal leading-relaxed leading-loose leading-7line-height
tracking-tighter tracking-tight tracking-normal tracking-wide tracking-widestletter-spacing
text-left text-center text-right text-justify text-start text-endtext-align
underline overline line-through no-underlinetext-decoration-line
decoration-2 decoration-dotted decoration-sky-500 underline-offset-4Decoration thickness, style, colour, offset
uppercase lowercase capitalize normal-casetext-transform
italic not-italicfont-style
truncateoverflow-hidden text-ellipsis whitespace-nowrap
line-clamp-3 line-clamp-noneClamp to N lines with an ellipsis
text-wrap text-nowrap text-balance text-prettytext-wrap — balance for headings, pretty for body
wrap-break-word wrap-anywhereBreak long strings v4.1
break-all break-keep whitespace-pre-wrapWord breaking and whitespace
list-disc list-decimal list-inside marker:text-gray-400Lists and markers
align-middle hyphens-auto content-['—']Vertical alignment, hyphenation, pseudo content
tab-4 font-features-*Tab size v4.3 and OpenType features v4.2

Colors#

GroupFamilies
Warmred orange amber yellow
Greenlime green emerald teal
Bluecyan sky blue indigo
Purple/pinkviolet purple fuchsia pink rose
Neutralslate gray zinc neutral stone
Muted v4.2mauve olive mist taupe

Every family has eleven steps: 50 100 200 300 400 500 600 700 800 900 950. Plus black, white, transparent, current and inherit.

ClassCSS / Effect
text-* bg-* border-* outline-*Text, background, border, outline colour
ring-* inset-ring-* shadow-* inset-shadow-*Ring and shadow colour
drop-shadow-* text-shadow-*Coloured shadows v4.1
divide-* decoration-* accent-* caret-*Dividers, underlines, form controls, caret
fill-* stroke-*SVG
from-* via-* to-*Gradient stops
placeholder:text-* selection:bg-* marker:text-*Pseudo-element colour
scrollbar-thumb-* scrollbar-track-*Scrollbars v4.3
bg-sky-500/10 text-black/75Opacity modifier — any percentage
opacity-50Whole-element opacity, children included

Backgrounds & Gradients#

ClassCSS / Effect
bg-white bg-transparent bg-currentbackground-color
bg-[url(/hero.jpg)] bg-nonebackground-image
bg-cover bg-contain bg-autobackground-size
bg-center bg-top bg-bottom bg-left bg-rightbackground-position
bg-no-repeat bg-repeat bg-repeat-xbackground-repeat
bg-fixed bg-local bg-scrollbackground-attachment
bg-clip-text bg-clip-border bg-clip-paddingbackground-clip — text for gradient headlines
bg-origin-border bg-origin-padding bg-origin-contentbackground-origin
bg-linear-to-r bg-linear-to-br bg-linear-45Linear gradients — renamed from bg-gradient-to-*
bg-radial bg-conic bg-conic-180Radial and conic gradients v4
from-cyan-500 via-sky-500 to-blue-600Gradient stop colours
from-10% via-30% to-90%Gradient stop positions
bg-linear-to-r/oklchInterpolate the gradient in a wider colour space
mask-*Gradient and image masks v4.1

Borders & Radius#

ClassCSS / Effect
border border-0 border-2 border-4 border-8border-width — colour defaults to currentColor in v4
border-x border-y border-t-2 border-bPer-axis and per-side widths
border-s border-eLogical sides, flip in RTL
border-gray-200 border-transparentborder-color
border-solid -dashed -dotted -double -hidden -noneborder-style
divide-y divide-x-2 divide-dashed divide-gray-200Borders between children
rounded-none rounded-xs rounded-sm rounded-md rounded-lg0, 2px, 4px, 6px, 8px
rounded-xl rounded-2xl rounded-3xl rounded-4xl rounded-full12px, 16px, 24px, 32px, pill
rounded-t-lg rounded-br-md rounded-ss-xlPer side, per corner, logical corner
outline outline-2 outline-offset-2 outline-dashedoutline — sits outside the box, no layout shift
outline-hiddenRemoves the outline but keeps it in forced-colours mode
outline-noneoutline-style: none — only with a replacement focus style

Shadows & Rings#

ClassCSS / Effect
shadow-2xs shadow-xs shadow-sm shadow-mdRising elevation — shadow-sm is the v3 shadow
shadow-lg shadow-xl shadow-2xl shadow-noneDropdowns, modals, hero elements
shadow-indigo-500/40Coloured shadow with alpha
inset-shadow-2xs inset-shadow-xs inset-shadow-sm inset-shadow-noneInner shadows
text-shadow-2xs … text-shadow-lg text-shadow-nonetext-shadow v4.1
drop-shadow-xs … drop-shadow-2xlfilter: drop-shadow() — follows alpha edges, use on PNGs and SVGs
ring ring-2 ring-4 ring-8 ring-0Ring width — ring is 1px in v4, ring-3 matches the v3 ring
ring-indigo-500Ring colour — defaults to currentColor in v4
inset-ring inset-ring-2 inset-ring-white/10Ring drawn inside the border box

Filters & Effects#

ClassCSS / Effect
blur-xs blur-sm blur-md blur-lg blur-xl blur-2xl blur-3xl4, 8, 12, 16, 24, 40, 64px
brightness-50 brightness-125filter: brightness()
contrast-50 contrast-200filter: contrast()
saturate-0 saturate-150filter: saturate()
grayscale grayscale-50 sepia invertColour filters
hue-rotate-90 -hue-rotate-15filter: hue-rotate()
filter-noneClear all filters
backdrop-blur-md backdrop-brightness-75 backdrop-saturate-150Filter what is behind the element
backdrop-filter-noneClear all backdrop filters
opacity-0 opacity-50 opacity-100opacity
mix-blend-multiply mix-blend-overlaymix-blend-mode
bg-blend-screenbackground-blend-mode

Filters compose within one element — blur-sm grayscale applies both.

Transitions & Animation#

ClassCSS / Effect
transitionColours, opacity, shadow, transform, filter, backdrop-filter
transition-all transition-colors transition-opacity transition-shadow transition-transformNarrower property sets
transition-noneDisable
duration-150 duration-300 duration-500transition-duration — default is 150ms
delay-100transition-delay
ease-linear ease-in ease-out ease-in-out ease-initialtransition-timing-function
transition-discretetransition-behavior: allow-discrete — animate display changes
starting:opacity-0@starting-style — the entry value v4
animate-spinspin 1s linear infinite
animate-pingping 1s cubic-bezier(0, 0, 0.2, 1) infinite
animate-pulsepulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite
animate-bouncebounce 1s infinite
animate-noneanimation: none
motion-safe: motion-reduce:Respect prefers-reduced-motion
will-change-transform will-change-autowill-change — remove once the animation ends

Transforms#

ClassCSS / Effect
scale-95 scale-105 scale-x-50 scale-y-150scale
rotate-45 -rotate-3rotate
translate-x-4 -translate-y-2 translate-x-1/2translate
skew-x-6 skew-y-3skew
origin-center origin-top-left origin-[30%_60%]transform-origin
perspective-near perspective-normal perspective-distant300px, 500px, 1200px v4
perspective-origin-topperspective-origin
transform-3d transform-flattransform-style: preserve-3d / flat
rotate-x-30 rotate-y-45 translate-z-8 scale-z-1103D transforms v4
backface-hidden backface-visiblebackface-visibility
transform-gpu transform-cpu transform-noneCompositing hints and reset
zoom-75 zoom-100 zoom-125zoom — scales the layout box too v4.3

Responsive breakpoints#

Mobile first: an unprefixed utility applies everywhere, a prefixed one applies from that width up.

VariantMin widthMedia query
sm:40rem / 640px@media (width >= 40rem)
md:48rem / 768px@media (width >= 48rem)
lg:64rem / 1024px@media (width >= 64rem)
xl:80rem / 1280px@media (width >= 80rem)
2xl:96rem / 1536px@media (width >= 96rem)
max-md:below 48rem@media (width < 48rem)
min-[900px]:arbitrary@media (width >= 900px)

Container query sizes#

Mark an ancestor @container, then size against it instead of the viewport.

VariantMin widthVariantMin width
@3xs16rem@2xl42rem
@2xs18rem@3xl48rem
@xs20rem@4xl56rem
@sm24rem@5xl64rem
@md28rem@6xl72rem
@lg32rem@7xl80rem
@xl36rem@max-mdbelow 28rem

Name containers when they nest: @container/card then @lg/card:flex.

States & Variants#

VariantApplies when
hover:Pointer over the element — wrapped in @media (hover: hover)
focus: focus-visible: focus-within:Focused, focus should be shown, a descendant is focused
active: visited: target:Pressed, visited link, URL fragment target
disabled: enabled: checked: indeterminate:Form control state
required: valid: invalid: user-invalid:Validation — prefer user-invalid:
placeholder-shown: read-only: autofill:Input content and mode
first: last: only: odd: even: empty:Structural position
*: **:Direct children / all descendants
group-hover: group-focus:React to an ancestor marked group
peer-checked: peer-user-invalid:React to an earlier sibling marked peer
has-checked: has-[a]:Style a parent from its children
not-hover: in-[.sidebar]:Negation and ancestor matching v4
open: inert: details-content:<details>, popovers, inert subtrees v4
before: after: placeholder: selection: marker: file: backdrop:Pseudo-elements
aria-expanded: data-[state=open]:Attribute matching
rtl: ltr: print:Direction and print
supports-[backdrop-filter]:@supports feature query
[&_p]:mt-4Arbitrary selector — & is the element, _ is a space

The complete table is on the Variant Reference page.

Dark mode#

ClassCSS / Effect
dark:bg-gray-900@media (prefers-color-scheme: dark) by default
scheme-light scheme-dark scheme-light-darkcolor-scheme — fixes native scrollbars and form controls

Switch to a class-driven toggle by redefining the variant:

app.css
@import "tailwindcss";
@custom-variant dark (&:where(.dark, .dark *));

Accessibility#

ClassCSS / Effect
sr-onlyVisually hidden, still read by screen readers
not-sr-onlyUndo sr-only — pair as sr-only focus:not-sr-only for skip links
focus-visible:outline-2Focus ring only when the browser judges one is warranted
outline-hiddenHide the outline without breaking forced-colours mode
motion-reduce:transition-none@media (prefers-reduced-motion: reduce)
motion-safe:animate-bounceOnly animate when motion is welcome
contrast-more:border-gray-900@media (prefers-contrast: more)
forced-colors:outlineWindows High Contrast mode
forced-color-adjust-noneOpt an element out of forced colour substitution
aria-hidden:hidden aria-expanded:rotate-180Style from ARIA state, keeping markup and CSS in sync

Renamed and removed in v4#

v3v4
shadow-sm / shadowshadow-xs / shadow-sm
drop-shadow-sm / drop-shadowdrop-shadow-xs / drop-shadow-sm
blur-sm / blurblur-xs / blur-sm
rounded-sm / roundedrounded-xs / rounded-sm
outline-noneoutline-hidden
ringring-3 — bare ring is now 1px
bg-gradient-to-rbg-linear-to-r
flex-shrink-* / flex-grow-*shrink-* / grow-*
overflow-ellipsistext-ellipsis
bg-opacity-50 and friendsbg-black/50 — the opacity modifier

Common mistakes#

  • Building class names from strings. bg-${color}-500 never reaches the compiler. Map props to complete class names — see Troubleshooting.
  • truncate without min-w-0. A flex item defaults to min-width: auto and refuses to shrink below its content.
  • Reaching for space-x-* first. gap-* is the better default; space-* exists for cases where gap cannot apply.
  • Assuming border draws grey. In v4 the default border colour is currentColor. Always pair it: border border-gray-200.
  • ring where you meant ring-3. The v4 default ring is 1px currentColor, not 3px blue.