Tailwind CSS Cheatsheet
Utility-first reference. Covers every major category: layout, flexbox/grid, spacing, sizing, typography, backgrounds, borders, effects, filters, tables, transitions, transforms, interactivity, SVG, accessibility, and variants. Compatible with Tailwind v3 and v4 (v4-only utilities tagged).
1 credit
Responsive breakpointsState variantsDisplayPositionOverflow & objectFloat, clear, containerFlexboxGridSpace between siblingsPadding & marginWidth & heightFontText layoutTypography detailColors (text, bg, border, …)BackgroundsBorders & radiiOutline & ringShadows, opacity, blendFiltersTransformsTransitions & animationInteractivityTablesSVGAccessibilityArbitrary values & CSS varsPseudo-elements & contentv4 additions (highlights)Config essentials (v3)@apply / @layer / @variantsDev ergonomics
Responsive breakpoints
9 itemssm (≥640px)
sm:flex sm:text-lg sm:px-6md (≥768px)
md:grid-cols-2 md:gap-8lg (≥1024px)
lg:flex-row lg:w-1/2xl (≥1280px)
xl:container xl:text-xl2xl (≥1536px)
2xl:max-w-screen-2xlMin arbitrary
min-[720px]:flexMax (cap at)
max-md:hidden max-lg:flex-colMax arbitrary
max-[900px]:blockMobile-first rule
Base = mobile. Add prefixes for larger.Design small-first; override up.
State variants
23 itemsHovercommon
hover:bg-primary/90 hover:underlineFocusa11y
focus:ring-2 focus:outline-noneFocus-visiblea11y
focus-visible:ring-2Keyboard focus only — hides on click
Focus-within
focus-within:ring-2Active / visited
active:scale-95 visited:text-purple-700Disabled / enabled
disabled:opacity-50 disabled:cursor-not-allowed enabled:hover:bg-primaryCheckedform
checked:bg-primary checked:border-transparentPlaceholder-shown
placeholder-shown:border-mutedInvalid / required / valid
invalid:border-red-500 required:bg-amber-50 valid:border-emerald-500Read-only
read-only:bg-mutedFirst / last / only
first:pt-0 last:border-0 only:mx-autoOdd / even
odd:bg-muted/30 even:bg-muted/10Empty
empty:hiddenTarget
target:ring-2Open (<details>, <dialog>)
open:bg-mutedGroup + peercompose
group group-hover:visible peer peer-checked:border-primaryData attribute
data-[state=open]:rotate-180ARIA attribute
aria-expanded:rotate-90 aria-disabled:opacity-60Motion
motion-safe:animate-spin motion-reduce:animate-nonePrint
print:hidden print:text-blackDark mode
dark:bg-slate-900 dark:text-whiteNegationv4+
not-first:pl-4 not-last:mr-2 not-hover:opacity-50Supportsprogressive
supports-[display:grid]:gridDisplay
8 itemsBlock / inline
block inline-block inlineFlex
flex inline-flexGrid
grid inline-gridTable parts
table table-row table-cell table-caption table-header-group table-footer-groupList item
list-itemHidden
hidden (display: none)Contents
contents (element box disappears; children promote)Flow-root
flow-root (new BFC — clears floats)Position
6 itemsPositioning
static relative absolute fixed stickyTop/right/etc.
top-0 right-4 bottom-2 left-1/2 -top-2Inset shorthand
inset-0 inset-x-4 inset-y-0 inset-1/2Z-index
z-0 z-10 z-20 z-30 z-40 z-50 z-auto -z-10 z-[60]Visibility
visible invisible collapseIsolation
isolate isolation-autoOverflow & object
8 itemsOverflow
overflow-auto overflow-hidden overflow-clip overflow-visible overflow-scrollOverflow x/y
overflow-x-auto overflow-y-hiddenOverscroll
overscroll-none overscroll-contain overscroll-y-autoObject-fit
object-contain object-cover object-fill object-none object-scale-downObject-position
object-top object-center object-bottom object-left object-right object-[25%_75%]Aspect ratio
aspect-auto aspect-square aspect-video aspect-[4/3]Box sizing
box-border box-contentBox decoration
box-decoration-clone box-decoration-sliceFloat, clear, container
6 itemsFloat
float-left float-right float-none float-start float-endClear
clear-left clear-right clear-both clear-none clear-start clear-endContainer
container (sets max-width to the current breakpoint)Combine with `mx-auto px-4` in most designs
Columns
columns-1 columns-2 … columns-12 columns-auto columns-3xs columns-2xs columns-xs … columns-7xlBreak inside
break-inside-auto break-inside-avoid break-inside-avoid-page break-inside-avoid-columnBreak before/after
break-after-page break-before-column break-after-avoidFlexbox
10 itemsDirection
flex-row flex-row-reverse flex-col flex-col-reverseWrap
flex-wrap flex-wrap-reverse flex-nowrapFlex shorthand
flex-1 flex-auto flex-initial flex-none flex-[2_1_0%]Grow / shrink
grow grow-0 shrink shrink-0Order
order-1 … order-12 order-first order-last order-noneBasis
basis-0 basis-1/2 basis-1/3 basis-full basis-auto basis-64 basis-[10ch]Justify content
justify-start justify-end justify-center justify-between justify-around justify-evenly justify-normal justify-stretchAlign items
items-start items-end items-center items-baseline items-stretchAlign self
self-auto self-start self-center self-end self-stretch self-baselineGap
gap-0 gap-1 gap-2 … gap-96 gap-x-4 gap-y-2 gap-[18px]Grid
9 itemsTemplate cols
grid-cols-1 … grid-cols-12 grid-cols-none grid-cols-subgrid (v4) grid-cols-[200px_1fr_auto]Template rows
grid-rows-1 … grid-rows-6 grid-rows-none grid-rows-subgrid (v4)Column span
col-auto col-span-1 … col-span-12 col-span-fullColumn start/end
col-start-1 … col-start-13 col-end-1 … col-end-13Row span
row-auto row-span-1 … row-span-6 row-span-fullAuto flow
grid-flow-row grid-flow-col grid-flow-dense grid-flow-row-dense grid-flow-col-denseAuto cols/rows
auto-cols-auto auto-cols-min auto-cols-max auto-cols-fr auto-rows-*Justify / align (grid)
justify-items-center place-items-center place-content-between place-self-endNamed areas
grid-areas-[...] (v4) — define via templateSpace between siblings
3 itemsHorizontal / vertical
space-x-0 … space-x-96 space-y-4 space-x-px space-y-[18px]Reverse (flex-row-reverse)
space-x-reverse space-y-reverseDivide (border between)
divide-x divide-y divide-x-2 divide-y-4 divide-slate-200 divide-dashed divide-y-reversePadding & margin
6 itemsPaddingscale
p-0 p-px p-0.5 p-1 p-2 p-4 p-8 p-16 p-96 p-[13px]Padding axis
px-4 py-2 ps-4 (start) pe-2 (end)Padding side
pt-0 pr-1 pb-2 pl-4Margin
m-0 m-auto m-4 m-96 -m-2 (negative) m-[5vh]Margin axis/side
mx-auto my-4 mt/mr/mb/ml-* ms-/me-*Scale valuesscale
0, px, 0.5, 1..4 (0.25rem steps), 5..12 (0.25rem), 14, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 72, 80, 96Width & height
11 itemsWidth (fixed)
w-0 w-px w-1 w-8 w-64 w-96Width (fractions)
w-1/2 w-1/3 w-2/3 w-1/4 … w-11/12 w-fullWidth (viewport)v3.4+
w-screen w-svw w-lvw w-dvwWidth (intrinsic)
w-auto w-min w-max w-fitMin / max width
min-w-0 min-w-full min-w-fit max-w-xs..7xl max-w-prose max-w-screen-md max-w-noneHeight (fixed)
h-0 h-px h-4 h-64 h-96Height (viewport)
h-screen h-svh h-lvh h-dvhHeight (intrinsic)
h-auto h-min h-max h-fitMin / max height
min-h-0 min-h-screen min-h-dvh max-h-96 max-h-screenSize shorthandv3.4+
size-4 size-10 size-full (sets w + h together)Arbitrary
w-[125px] h-[calc(100vh-3rem)] max-w-[72ch]Font
6 itemsFamily
font-sans font-serif font-monoSize
text-xs text-sm text-base text-lg text-xl text-2xl text-3xl … text-9xl text-[17px]Weight
font-thin extralight light normal medium semibold bold extrabold blackStyle
italic not-italicSmoothing
antialiased subpixel-antialiasedVariant numeric
normal-nums ordinal slashed-zero lining-nums oldstyle-nums proportional-nums tabular-nums diagonal-fractions stacked-fractionsText layout
9 itemsAlign
text-left text-center text-right text-justify text-start text-endWrapv3.4+
text-wrap text-nowrap text-balance text-prettyWhitespace
whitespace-normal nowrap pre pre-line pre-wrap break-spacesWord break
break-normal break-words break-all break-keepHyphens
hyphens-none hyphens-manual hyphens-autoOverflow
truncate text-ellipsis text-clipLine clamp
line-clamp-1 … line-clamp-6 line-clamp-noneIndent
indent-0 indent-px indent-4 indent-8 -indent-4 indent-[2ch]Vertical-align
align-baseline align-top align-middle align-bottom align-text-top align-text-bottom align-sub align-superTypography detail
10 itemsLetter spacing
tracking-tighter tighter tight normal wide wider widestLine height
leading-3 … leading-10 leading-none leading-tight leading-snug leading-normal leading-relaxed leading-looseText transform
uppercase lowercase capitalize normal-caseText decoration
underline overline line-through no-underlineDecoration color
decoration-current decoration-transparent decoration-slate-500 decoration-[#xxx]Decoration style
decoration-solid decoration-dashed dotted double wavyDecoration thickness
decoration-auto decoration-from-font decoration-0 1 2 4 8Underline offset
underline-offset-auto 0 1 2 4 8List style
list-disc list-decimal list-noneList position
list-inside list-outsideColors (text, bg, border, …)
10 itemsPalettespalette
slate gray zinc neutral stone red orange amber yellow lime green emerald teal cyan sky blue indigo violet purple fuchsia pink roseScale (per palette)
50 100 200 300 400 500 600 700 800 900 950Specials
inherit current transparent black whiteWith opacity
bg-primary/10 text-white/80 border-slate-200/50Text color
text-slate-900 text-emerald-500 text-currentBackground
bg-white bg-blue-500 bg-[#1d4ed8]Border color
border-slate-200 border-inheritPlaceholder
placeholder-slate-400 placeholder:italicCaret
caret-primary caret-transparentAccent
accent-primary (native inputs — checkbox, progress)Backgrounds
9 itemsAttachment
bg-fixed bg-local bg-scrollClip
bg-clip-border bg-clip-padding bg-clip-content bg-clip-textOrigin
bg-origin-border bg-origin-padding bg-origin-contentPosition
bg-bottom bg-center bg-left bg-left-bottom bg-left-top bg-right bg-top bg-[25%_75%]Repeat
bg-repeat bg-no-repeat bg-repeat-x bg-repeat-y bg-repeat-round bg-repeat-spaceSize
bg-auto bg-cover bg-contain bg-[length:200px_auto]Image (gradient)
bg-gradient-to-t bg-gradient-to-tr bg-gradient-to-r bg-gradient-to-br bg-gradient-to-b bg-gradient-to-bl bg-gradient-to-l bg-gradient-to-tlGradient stops
from-pink-500 via-purple-500 to-violet-500 from-10% via-30% to-90%Image (custom)
bg-[url('data:,')] bg-noneReplace data:, with your own URL — e.g. url('/hero.webp'). Keep it absolute so Next/Webpack passes it through.
Borders & radii
7 itemsRadius (uniform)
rounded-none rounded-sm rounded rounded-md rounded-lg rounded-xl rounded-2xl rounded-3xl rounded-fullRadius per corner
rounded-t-lg rounded-r-lg rounded-b-lg rounded-l-lg rounded-tl-lg rounded-tr-lg rounded-bl-lg rounded-br-lgRadius logical
rounded-s rounded-e rounded-ss rounded-se rounded-es rounded-eeWidth (all)
border-0 border border-2 border-4 border-8 border-[3px]Width per side
border-t-2 border-r border-b-0 border-l-4 border-x-2 border-yStyle
border-solid border-dashed border-dotted border-double border-hidden border-noneColor
border-slate-200 border-transparent border-current border-[#xxx]Outline & ring
6 itemsOutline width
outline-0 outline-1 outline-2 outline-4 outline-8 outline outline-noneOutline style
outline-solid outline-dashed outline-dotted outline-doubleOutline color
outline-primary outline-offset-2Ring
ring ring-0 ring-1 ring-2 ring-4 ring-8 ring-insetRing color
ring-primary ring-primary/50Ring offset
ring-offset-0 ring-offset-2 ring-offset-whiteShadows, opacity, blend
6 itemsBox shadow
shadow-sm shadow shadow-md shadow-lg shadow-xl shadow-2xl shadow-inner shadow-noneShadow color
shadow-primary/25 shadow-black/50Opacity
opacity-0 opacity-25 opacity-50 opacity-75 opacity-100 opacity-[0.65]Mix blend mode
mix-blend-normal mix-blend-multiply screen overlay darken lighten color-dodge color-burn hard-light soft-light difference exclusion hue saturation color luminosityBg blend mode
bg-blend-normal bg-blend-multiply …Text shadow
text-shadow-[0_1px_2px_rgba(0,0,0,0.5)] (arbitrary only)Filters
9 itemsApply filter
filter filter-noneBlur
blur-none blur-sm blur blur-md blur-lg blur-xl blur-2xl blur-3xl blur-[2px]Brightness
brightness-0 brightness-50 brightness-100 brightness-150 brightness-200Contrast
contrast-0 50 100 150 200Grayscale / invert / sepia
grayscale grayscale-0 invert invert-0 sepia sepia-0Hue rotate
hue-rotate-0 15 30 60 90 180 -hue-rotate-60 hue-rotate-[72deg]Saturate
saturate-0 50 100 150 200Drop shadow
drop-shadow-sm drop-shadow drop-shadow-md lg xl 2xl noneBackdrop variants
backdrop-blur backdrop-brightness backdrop-contrast backdrop-grayscale backdrop-hue-rotate backdrop-invert backdrop-opacity backdrop-saturate backdrop-sepiaTransforms
7 itemsEnable (legacy)
transform transform-gpu transform-none (v3 only — v4 auto)Scale
scale-0 scale-50 scale-75 scale-90 scale-95 scale-100 scale-105 scale-110 scale-125 scale-150 -scale-100Scale axis
scale-x-100 scale-y-50Rotate
rotate-0 rotate-1 rotate-2 rotate-3 rotate-6 rotate-12 rotate-45 rotate-90 rotate-180 -rotate-45 rotate-[17deg]Translate
translate-x-1/2 translate-y-full -translate-y-1/4 translate-x-[-50%]Skew
skew-x-0 skew-x-1 skew-x-12 -skew-y-6 skew-y-[9deg]Origin
origin-center top bottom left right top-left top-right bottom-left bottom-rightTransitions & animation
6 itemsProperty
transition transition-none transition-all transition-colors transition-opacity transition-shadow transition-transformDuration
duration-75 100 150 200 300 500 700 1000 duration-[250ms]Easing
ease-linear ease-in ease-out ease-in-out ease-[cubic-bezier(0.4,0,0.2,1)]Delay
delay-75 100 150 200 300 500 700 1000Animate
animate-none animate-spin animate-ping animate-pulse animate-bounceCustom keyframes
theme.extend.keyframes + theme.extend.animation in tailwind.configInteractivity
11 itemsCursor
cursor-auto default pointer wait text move help not-allowed none context-menu progress cell crosshair vertical-text alias copy no-drop grab grabbing all-scroll col-resize row-resize n-resize e-resize s-resize w-resize ne-resize nw-resize se-resize sw-resize ew-resize ns-resize nesw-resize nwse-resize zoom-in zoom-outPointer events
pointer-events-none pointer-events-autoResize
resize-none resize-y resize-x resizeUser select
select-none select-text select-all select-autoAppearance
appearance-none appearance-autoTouch action
touch-auto touch-none touch-pan-x touch-pan-left touch-pan-right touch-pan-y touch-pan-up touch-pan-down touch-pinch-zoom touch-manipulationWill change
will-change-auto will-change-scroll will-change-contents will-change-transformCaret color
caret-primary caret-transparentScroll behavior
scroll-auto scroll-smoothScroll margin / padding
scroll-mt-16 scroll-pt-16 scroll-mx-4 scroll-py-2Scroll snap
snap-none snap-x snap-y snap-both snap-mandatory snap-proximity snap-start snap-end snap-center snap-align-none snap-normal snap-alwaysTables
4 itemsBorder collapse
border-collapse border-separateBorder spacing
border-spacing-0 border-spacing-px border-spacing-1 border-spacing-2 border-spacing-[7px] border-spacing-x-1 border-spacing-y-4Layout
table-auto table-fixedCaption side
caption-top caption-bottomSVG
3 itemsFill
fill-none fill-current fill-inherit fill-transparent fill-slate-900 fill-[#xxx]Stroke color
stroke-current stroke-slate-400 stroke-[#xxx]Stroke width
stroke-0 stroke-1 stroke-2 stroke-[1.5]Accessibility
3 itemsScreen reader
sr-only not-sr-onlyVisually hidden but still announced
Forced colors
forced-color-adjust-auto forced-color-adjust-noneFocus ring patternpattern
outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2Arbitrary values & CSS vars
7 itemsArbitrary value
w-[137px] text-[#bada55] grid-cols-[auto_1fr_auto] hover:bg-[url('data:,')]CSS var reference
bg-[var(--brand)] text-[var(--accent)] rounded-[var(--r)]Typed arbitrary
bg-[image:url('data:,')] bg-[length:200px_auto] text-[color:var(--x)]Arbitrary variant
[&:nth-child(3)]:bg-red-500 [&>svg]:text-currentdata-* variant
data-[state=open]:bg-primaryaria-* variant
aria-checked:border-primary aria-expanded:rotate-180group tag
group/item group-hover/item:visible (named groups for nested contexts)Pseudo-elements & content
9 items::before / ::after
before:content-['→'] before:mr-2 after:content-[''] after:blockEmpty content
after:content-[''] (required for ::after to render without text)CSS var content
content-[var(--prefix)]First-letter / line
first-letter:uppercase first-line:font-boldSelection
selection:bg-primary selection:text-whiteMarker (list)
marker:text-primary marker:font-boldFile input
file:mr-2 file:rounded-full file:bg-primaryPlaceholder
placeholder:italic placeholder:text-slate-400Backdrop (<dialog>)
backdrop:bg-black/50 backdrop:blur-smv4 additions (highlights)
6 itemsStarting stylev4
starting:opacity-0 (for @starting-style transitions)Container queries (built-in)v4
@container @sm:grid-cols-2 @md:flex @[400px]:…field-sizingv4
field-sizing-content (textarea auto-grow)Dynamic utility valuesv4
grid-cols-15 mt-17 (non-preset numbers now work)CSS-first configv4
@theme { --font-display: 'Inter'; } — no JS tailwind.config required3D transformsv4
rotate-x-12 rotate-y-45 translate-z-4 perspective-normalConfig essentials (v3)
javascript
/** @type {import('tailwindcss').Config} */
module.exports = {
content: ["./src/**/*.{ts,tsx}"],
darkMode: "class",
theme: {
extend: {
colors: { brand: { 50: "#f0f9ff", 500: "#0ea5e9", 900: "#0c4a6e" } },
fontFamily: { sans: ["Geist", "system-ui"] },
keyframes: { shake: { "0%,100%": { transform: "translateX(0)" }, "50%": { transform: "translateX(-4px)" } } },
animation: { shake: "shake 0.4s ease-in-out" },
},
},
plugins: [require("@tailwindcss/typography"), require("@tailwindcss/forms")],
};@apply / @layer / @variants
css
@layer components {
.btn {
@apply inline-flex items-center gap-2 rounded-md bg-primary px-3 py-1.5
text-sm font-medium text-primary-foreground
hover:bg-primary/90 focus-visible:ring-2 focus-visible:ring-ring;
}
}
@layer utilities {
.text-balance { text-wrap: balance; }
}Prefer pure utility classes in components; reserve @apply for truly repeated multi-utility patterns.
Dev ergonomics
- Install `prettier-plugin-tailwindcss` — sorts classes deterministically (saves bikeshedding in reviews).
- IntelliSense extension (VS Code / JetBrains) autocompletes classes + shows resolved CSS on hover.
- `cn()` helper (from clsx + tailwind-merge) handles conditional classes and dedupes conflicting utilities.
- Use `group` + `peer` to avoid state-lifting to parent components.
- Reach for `@apply` only when a 5+ utility combo repeats across many files.
- `tailwindcss/no-custom-classname` ESLint rule catches typos at build time.