Tailwind CSS Cheatsheet
Complete Tailwind CSS reference. Hit Ctrl+P to print.
Layout
blockDisplay blockinlineDisplay inlineinline-blockDisplay inline-blockflexDisplay flexinline-flexDisplay inline-flexgridDisplay gridinline-gridDisplay inline-gridcontentsDisplay contents - element acts as wrapper onlyflow-rootDisplay flow-root - establishes BFClist-itemDisplay list-item - renders bullet/markerhiddendisplay: nonestaticposition: static (default)relativeposition: relativeabsoluteposition: absolutefixedposition: fixedstickyposition: stickyinset-0top/right/bottom/left: 0inset-x-0left: 0; right: 0inset-y-0top: 0; bottom: 0top-0 / right-0 / bottom-0 / left-0Individual edge set to 0top-4 / top-8 / top-autotop with scale value or autooverflow-autoScroll when content overflowsoverflow-hiddenClip overflowing contentoverflow-scrollAlways show scrollbarsoverflow-clipClip content without enabling programmatic scrollingoverflow-visibleContent renders outside boundsoverflow-x-auto / overflow-y-autoAxis-specific overflowz-0 / z-10 / z-20 / z-30 / z-40 / z-50z-index scalez-autoz-index: autovisible / invisiblevisibility: visible / hidden (space preserved)isolateisolation: isolate - creates stacking contextisolation-autoisolation: autofloat-left / float-right / float-noneFloat elementclear-left / clear-right / clear-both / clear-noneClear floatsobject-contain / object-cover / object-fill / object-none / object-scale-downobject-fit valuesobject-center / object-top / object-bottomobject-position valuesFlexbox
flex-rowflex-direction: row (default)flex-row-reverseflex-direction: row-reverseflex-colflex-direction: columnflex-col-reverseflex-direction: column-reverseflex-wrapflex-wrap: wrapflex-nowrapflex-wrap: nowrapflex-wrap-reverseflex-wrap: wrap-reversejustify-startjustify-content: flex-startjustify-endjustify-content: flex-endjustify-centerjustify-content: centerjustify-betweenjustify-content: space-betweenjustify-aroundjustify-content: space-aroundjustify-evenlyjustify-content: space-evenlyjustify-stretchjustify-content: stretchitems-startalign-items: flex-startitems-endalign-items: flex-enditems-centeralign-items: centeritems-baselinealign-items: baselineitems-stretchalign-items: stretchself-auto / self-start / self-end / self-center / self-stretch / self-baselinealign-self on individual itemcontent-start / content-end / content-center / content-between / content-around / content-evenlyalign-content for multi-line flexflex-1flex: 1 1 0% - grow/shrink equallyflex-autoflex: 1 1 auto - grow/shrink based on sizeflex-initialflex: 0 1 auto - default flex behaviourflex-noneflex: none - neither grow nor shrinkgrow / grow-0flex-grow: 1 / 0shrink / shrink-0flex-shrink: 1 / 0basis-0 / basis-full / basis-1/2 / basis-autoflex-basis valuesorder-first / order-last / order-noneorder: -9999 / 9999 / 0order-1 … order-12Explicit order valuesgap-4gap: 1rem (both axes)gap-x-4 / gap-y-4Column / row gapGrid
grid-cols-1 … grid-cols-12grid-template-columns: repeat(N, minmax(0,1fr))grid-cols-nonegrid-template-columns: nonegrid-cols-subgridgrid-template-columns: subgrid (v4)grid-rows-1 … grid-rows-6grid-template-rows: repeat(N, minmax(0,1fr))grid-rows-none / grid-rows-subgridNo rows template / subgridcol-span-1 … col-span-12grid-column: span N / span Ncol-span-fullgrid-column: 1 / -1 - full widthcol-start-1 … col-start-13 / col-start-autogrid-column-startcol-end-1 … col-end-13 / col-end-autogrid-column-endrow-span-1 … row-span-6 / row-span-fullgrid-row: span Nrow-start-1 … row-start-7 / row-start-autogrid-row-startrow-end-1 … row-end-7 / row-end-autogrid-row-endgrid-flow-rowgrid-auto-flow: rowgrid-flow-colgrid-auto-flow: columngrid-flow-densegrid-auto-flow: densegrid-flow-row-dense / grid-flow-col-denserow dense / col dense auto flowauto-cols-auto / auto-cols-min / auto-cols-max / auto-cols-frgrid-auto-columns valuesauto-rows-auto / auto-rows-min / auto-rows-max / auto-rows-frgrid-auto-rows valuesplace-items-start / place-items-center / place-items-end / place-items-stretchShorthand for align+justify itemsplace-content-start / place-content-center / place-content-betweenShorthand for align+justify contentplace-self-auto / place-self-start / place-self-center / place-self-stretchShorthand for align+justify selfSpacing
p-0 / p-0.5 / p-1 … p-96padding (all sides)px-4 / py-4Horizontal / vertical paddingpt-4 / pr-4 / pb-4 / pl-4Individual side paddingps-4 / pe-4Logical padding-inline-start / endm-0 / m-automargin: 0 / autom-0.5 / m-1 … m-96margin scale-m-4Negative marginmx-4 / my-4Horizontal / vertical marginmx-autoCentre block horizontallymt-4 / mr-4 / mb-4 / ml-4Individual side marginms-4 / me-4Logical margin-inline-start / endspace-x-4Horizontal space between children via marginspace-y-4Vertical space between children via marginspace-x-reverse / space-y-reverseReverse direction for RTL or flex-reverseScale: 0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 72, 80, 96Default spacing scale (1 unit = 0.25rem)Sizing
w-autowidth: autow-fullwidth: 100%w-screenwidth: 100vww-svw / w-lvw / w-dvwSmall / large / dynamic viewport widthw-min / w-max / w-fitmin-content / max-content / fit-contentw-0 … w-96Fixed width from spacing scalew-1/2 / w-1/3 / w-2/3 / w-1/4 / w-3/4Fractional widthsw-1/5 / w-2/5 / w-3/5 / w-4/5Fifth-based fractional widthsh-auto / h-full / h-screenheight: auto / 100% / 100vhh-svh / h-lvh / h-dvhSmall / large / dynamic viewport heighth-min / h-max / h-fitmin-content / max-content / fit-contenth-0 … h-96Fixed height from spacing scalesize-4Sets both width and height (shorthand)size-full / size-screen / size-autosize shorthand with keywordmin-w-0 / min-w-full / min-w-min / min-w-max / min-w-fitmin-width valuesmax-w-xs / max-w-sm / max-w-md / max-w-lg / max-w-xlNamed max-width breakpointsmax-w-2xl … max-w-7xlLarger named max-widthsmax-w-full / max-w-min / max-w-max / max-w-fitmax-width keyword valuesmax-w-prosemax-width: 65ch - optimal reading widthmax-w-screen-sm … max-w-screen-2xlmax-width matching breakpointsmin-h-0 / min-h-full / min-h-screen / min-h-svh / min-h-dvhmin-height valuesmax-h-full / max-h-screen / max-h-svh / max-h-dvh / max-h-96max-height valuesTypography
font-sans / font-serif / font-monoFont family stackstext-xs / text-sm / text-base / text-lg / text-xlFont size scale (0.75rem – 1.125rem)text-2xl / text-3xl / text-4xl / text-5xlLarger font sizes (1.5rem – 3rem)text-6xl / text-7xl / text-8xl / text-9xlDisplay sizes (3.75rem – 8rem)font-thin / font-extralight / font-lightFont weight 100 / 200 / 300font-normal / font-medium / font-semiboldFont weight 400 / 500 / 600font-bold / font-extrabold / font-blackFont weight 700 / 800 / 900leading-none / leading-tight / leading-snugline-height: 1 / 1.25 / 1.375leading-normal / leading-relaxed / leading-looseline-height: 1.5 / 1.625 / 2leading-3 … leading-10Fixed line-height from scaletracking-tighter / tracking-tight / tracking-normalletter-spacing: -0.05em / -0.025em / 0tracking-wide / tracking-wider / tracking-widestletter-spacing: 0.025em / 0.05em / 0.1emtext-left / text-right / text-center / text-justifytext-align valuestext-start / text-endLogical text-align (RTL-aware)uppercase / lowercase / capitalize / normal-casetext-transform valuesitalic / not-italicfont-style: italic / normalunderline / overline / line-through / no-underlinetext-decoration-line valuesdecoration-solid / decoration-double / decoration-dotted / decoration-dashed / decoration-wavytext-decoration-styledecoration-blue-500text-decoration-colordecoration-1 / decoration-2 / decoration-4text-decoration-thicknessunderline-offset-1 / underline-offset-2 / underline-offset-4 / underline-offset-8text-underline-offsetantialiased / subpixel-antialiased-webkit-font-smoothing grayscale / autotruncateoverflow:hidden; text-overflow:ellipsis; whitespace:nowraptext-ellipsis / text-cliptext-overflow: ellipsis / clipwhitespace-normal / whitespace-nowrap / whitespace-prewhite-space valueswhitespace-pre-line / whitespace-pre-wrap / whitespace-break-spacesMore white-space valuesbreak-normal / break-words / break-all / break-keepword-break / overflow-wrap ruleshyphens-none / hyphens-manual / hyphens-autohyphens propertyindent-4 / indent-8text-indentlist-none / list-disc / list-decimallist-style-typelist-inside / list-outsidelist-style-positiontext-wrap-wrap / text-wrap-nowrap / text-wrap-balance / text-wrap-prettytext-wrap (v4 / modern browsers)line-clamp-1 … line-clamp-6 / line-clamp-noneMulti-line text truncationColours & Backgrounds
text-gray-900 / text-gray-500 / text-gray-100Text colour with shadetext-{colour}-{50|100|200|300|400|500|600|700|800|900|950}Full text colour scaletext-black / text-white / text-transparent / text-current / text-inheritSpecial text coloursbg-blue-500Background colourbg-{colour}-{50-950}Full background colour scalebg-transparent / bg-current / bg-black / bg-white / bg-inheritSpecial background coloursbg-nonebackground-image: nonebg-gradient-to-t / bg-gradient-to-tr / bg-gradient-to-rLinear gradient directionsbg-gradient-to-br / bg-gradient-to-b / bg-gradient-to-bl / bg-gradient-to-l / bg-gradient-to-tlMore gradient directionsfrom-blue-500Gradient start colourvia-purple-500Gradient middle colourto-pink-500Gradient end colourfrom-0% / via-50% / to-100%Gradient stop positionsbg-fixed / bg-local / bg-scrollbackground-attachmentbg-clip-border / bg-clip-padding / bg-clip-content / bg-clip-textbackground-clipbg-repeat / bg-no-repeat / bg-repeat-x / bg-repeat-y / bg-repeat-round / bg-repeat-spacebackground-repeatbg-auto / bg-cover / bg-containbackground-sizebg-center / bg-top / bg-bottom / bg-left / bg-rightbackground-positiontext-blue-500/75Colour with opacity modifier (v3+)bg-blue-500/50Background with 50% opacityfill-blue-500 / stroke-blue-500SVG fill / stroke colourstroke-1 / stroke-2SVG stroke-widthBorders
borderborder-width: 1pxborder-0 / border-2 / border-4 / border-8border-width scaleborder-t / border-r / border-b / border-lSingle side border (1px)border-t-2 / border-x-4Side border with widthborder-gray-300 / border-blue-500border-colorborder-transparent / border-currentSpecial border coloursborder-solid / border-dashed / border-dotted / border-double / border-hidden / border-noneborder-stylerounded-noneborder-radius: 0rounded-sm / rounded / rounded-md / rounded-lgBorder radius scalerounded-xl / rounded-2xl / rounded-3xl / rounded-fullLarger border radius valuesrounded-t-lg / rounded-r-lg / rounded-b-lg / rounded-l-lgPer-side border radiusrounded-tl-lg / rounded-tr-lg / rounded-br-lg / rounded-bl-lgPer-corner border radiusdivide-x / divide-yBorder between children (horizontal / vertical)divide-x-2 / divide-y-4Divider with widthdivide-gray-200 / divide-blue-500Divider colourdivide-solid / divide-dashed / divide-dotted / divide-double / divide-noneDivider styledivide-x-reverse / divide-y-reverseReverse divider for RTL / flex-reversering-0 / ring-1 / ring-2 / ring / ring-4 / ring-8Box shadow ring (outline via shadow)ring-blue-500Ring colourring-insetRender ring inside elementring-offset-0 / ring-offset-1 / ring-offset-2 / ring-offset-4 / ring-offset-8Ring offset (gap between element and ring)ring-offset-white / ring-offset-gray-900Ring offset colouroutline-noneRemove default focus outlineoutline / outline-dashed / outline-dotted / outline-doubleoutline-style valuesoutline-blue-500outline-coloroutline-1 / outline-2 / outline-4outline-widthoutline-offset-0 / outline-offset-2 / outline-offset-4 / outline-offset-8outline-offsetEffects & Filters
shadow-sm / shadow / shadow-md / shadow-lg / shadow-xl / shadow-2xlbox-shadow scaleshadow-innerInset box shadowshadow-noneRemove box shadowshadow-blue-500/50Coloured shadow with opacityopacity-0 / opacity-5 / opacity-10 / opacity-25 / opacity-50 / opacity-75 / opacity-100Opacity scaleblur-none / blur-sm / blur / blur-md / blur-lg / blur-xl / blur-2xl / blur-3xlfilter: blur() scalebrightness-0 / brightness-50 / brightness-75 / brightness-90 / brightness-95 / brightness-100filter: brightness()brightness-105 / brightness-110 / brightness-125 / brightness-150 / brightness-200Increased brightness valuescontrast-0 / contrast-50 / contrast-75 / contrast-100 / contrast-125 / contrast-150 / contrast-200filter: contrast()grayscale / grayscale-0filter: grayscale(100%) / 0hue-rotate-0 / hue-rotate-15 / hue-rotate-30 / hue-rotate-60 / hue-rotate-90 / hue-rotate-180filter: hue-rotate()invert / invert-0filter: invert(100%) / 0saturate-0 / saturate-50 / saturate-100 / saturate-150 / saturate-200filter: saturate()sepia / sepia-0filter: sepia(100%) / 0drop-shadow-sm / drop-shadow / drop-shadow-md / drop-shadow-lg / drop-shadow-xlfilter: drop-shadow() (follows shape)backdrop-blur-sm … backdrop-blur-3xlbackdrop-filter: blur()backdrop-brightness-75 / backdrop-brightness-125backdrop-filter: brightness()backdrop-contrast-75 / backdrop-grayscale / backdrop-hue-rotate-30 / backdrop-invert / backdrop-saturate-200 / backdrop-sepiaOther backdrop-filter utilitiestransition-noneNo transitiontransition-allTransition all propertiestransition-colorsTransition color, background, border, etc.transition-opacityTransition opacitytransition-shadowTransition box-shadowtransition-transformTransition transformduration-75 / duration-100 / duration-150 / duration-200 / duration-300transition-durationduration-500 / duration-700 / duration-1000Longer transition durationsease-linear / ease-in / ease-out / ease-in-outtransition-timing-functiondelay-0 / delay-75 / delay-100 / delay-150 / delay-200 / delay-300 / delay-500 / delay-700 / delay-1000transition-delayanimate-noneanimation: noneanimate-spinContinuous 360° rotationanimate-pingPing/ripple effect (notification badges)animate-pulseFade opacity in/outanimate-bounceVertical bounceTransforms
scale-0 / scale-50 / scale-75 / scale-90 / scale-95 / scale-100transform: scale()scale-105 / scale-110 / scale-125 / scale-150Upscale valuesscale-x-75 / scale-y-125Axis-specific scalerotate-0 / rotate-1 / rotate-2 / rotate-3 / rotate-6 / rotate-12 / rotate-45 / rotate-90 / rotate-180transform: rotate()-rotate-45 / -rotate-90Negative rotationtranslate-x-4 / translate-y-4transform: translateX/Y()translate-x-1/2 / translate-x-fullFractional translate-translate-x-full / -translate-y-fullNegative translate (useful for off-screen)skew-x-1 / skew-x-2 / skew-x-3 / skew-x-6 / skew-x-12transform: skewX()skew-y-1 / skew-y-2 / skew-y-3 / skew-y-6 / skew-y-12transform: skewY()origin-centertransform-origin: centerorigin-top / origin-top-right / origin-right / origin-bottom-rightTransform origin positionsorigin-bottom / origin-bottom-left / origin-left / origin-top-leftMore transform origin positionstransform-gpuForce GPU-accelerated transform (translateZ hack)transform-nonetransform: none - reset all transformsperspective-none / perspective-dramatic / perspective-near / perspective-normal / perspective-distant3D perspective values (v4)rotate-x-12 / rotate-y-45 / rotate-z-63D rotation axes (v4)Interactivity
cursor-auto / cursor-default / cursor-pointerCommon cursor valuescursor-wait / cursor-text / cursor-move / cursor-help / cursor-not-allowedSemantic cursor valuescursor-grab / cursor-grabbingDrag cursor statescursor-none / cursor-progress / cursor-crosshair / cursor-cellOther cursor valuescursor-col-resize / cursor-row-resize / cursor-all-scrollResize / scroll cursorscursor-zoom-in / cursor-zoom-outZoom cursorsselect-noneuser-select: none - prevent text selectionselect-text / select-all / select-autoOther user-select valuesresize-none / resize-y / resize-x / resizeresize values for textareasscroll-auto / scroll-smoothscroll-behaviorscroll-m-4 / scroll-mx-4 / scroll-my-4scroll-marginscroll-p-4 / scroll-px-4 / scroll-py-4scroll-paddingsnap-start / snap-end / snap-center / snap-align-nonescroll-snap-alignsnap-mandatory / snap-proximityscroll-snap-type strictnesssnap-x / snap-y / snap-both / snap-nonescroll-snap-type axissnap-always / snap-normalscroll-snap-stopoverscroll-auto / overscroll-contain / overscroll-noneoverscroll-behavioroverscroll-x-auto / overscroll-y-containAxis-specific overscrollappearance-none / appearance-autoRemove / restore native widget stylingpointer-events-none / pointer-events-autoDisable / enable mouse eventstouch-auto / touch-none / touch-pan-x / touch-pan-y / touch-manipulationtouch-action valueswill-change-auto / will-change-scroll / will-change-contents / will-change-transformwill-change hints for browser optimisationcaret-transparent / caret-blue-500caret-color (text cursor colour)accent-blue-500accent-color for checkboxes/radios/rangeVariants
hover:bg-blue-600Apply on mouse hoverfocus:ring-2Apply on keyboard focusfocus-within:border-blue-500Apply when any child is focusedfocus-visible:outline-noneApply on keyboard (not mouse) focusactive:scale-95Apply while element is pressedvisited:text-purple-600Apply to visited linksdisabled:opacity-50Apply when element is disabledchecked:bg-blue-500Apply to checked checkboxes/radiosindeterminate:bg-gray-400Apply to indeterminate checkboxesplaceholder-shown:border-gray-300Apply while placeholder is visibleautofill:bg-yellow-50Apply when browser autofills a fieldrequired:border-red-500Apply to required form fieldsvalid:border-green-500 / invalid:border-red-500Form field validity statesin-range:bg-green-50 / out-of-range:bg-red-50Numeric input range statesread-only:bg-gray-100Apply to read-only inputsempty:hiddenApply when element has no childrenfirst:mt-0 / last:mb-0First / last childonly:mx-autoOnly childodd:bg-gray-50 / even:bg-whiteOdd / even childrenfirst-of-type:mt-0 / last-of-type:mb-0First / last of typetarget:ring-2Apply when element is URL fragment targetopen:rotate-180Apply to open /
sm: / md: / lg: / xl: / 2xl:Responsive: min-width breakpointsmax-sm: / max-md: / max-lg: / max-xl:Responsive: max-width breakpoints (v4)dark:bg-gray-900Apply in dark modemotion-safe:animate-spinApply only if user allows motionmotion-reduce:transition-noneApply when user prefers reduced motionprint:hiddenApply only in print mediaportrait:flex-col / landscape:flex-rowApply based on device orientationgroup / group-hover:text-blue-500Style children on parent hover - add group to parentgroup/name / group-hover/name:Named group for nested groupspeer / peer-checked:blockStyle siblings based on peer state - add peer to siblingpeer/name / peer-focus/name:Named peer for multiple peershas-[input:checked]:bg-blue-50Style parent based on descendant statenot-[.active]:opacity-50Apply when selector does NOT matchin-[.sidebar]:text-smApply when inside matching ancestordata-[state=open]:rotate-180Apply based on data-* attribute valuearia-[expanded=true]:bg-blue-100Apply based on aria-* attributeArbitrary Values & Important
w-[32px]Arbitrary width valueh-[calc(100vh-4rem)]Arbitrary calc() valuebg-[#ff0000]Arbitrary hex colourtext-[1.2rem]Arbitrary font sizemt-[clamp(1rem,5vw,3rem)]Arbitrary clamp() valuetext-[color:var(--my-color)]Arbitrary value with explicit type hintbg-[url(/img/hero.jpg)]Arbitrary background image URL[mask-type:alpha]Arbitrary CSS property shorthand[--my-var:1.5rem]Set a CSS custom property inlinegrid-cols-[200px_1fr_auto]Arbitrary grid templatetop-[var(--header-height)]Arbitrary CSS variable referencedata-[state=open]:blockArbitrary data-attribute variantsupports-[display:grid]:gridApply when browser supports feature!m-4Important modifier - adds !important!text-red-500Force colour with !importanthover:!opacity-100Important on hover variant@apply & Directives
@import "tailwindcss"v4: single import replaces three @tailwind directives@tailwind base; @tailwind components; @tailwind utilitiesv3: inject Tailwind layers@theme { --color-brand: oklch(60% 0.2 250); }v4: define design tokens in CSS@theme { --font-sans: "Inter", sans-serif; }v4: override default font family@theme { --spacing-18: 4.5rem; }v4: add custom spacing value@layer base { h1 { @apply text-3xl font-bold; } }Add to base layer with @apply@layer components { .btn { @apply px-4 py-2 rounded; } }Define reusable component class@layer utilities { .tab-4 { tab-size: 4; } }Add custom utility class@apply flex items-center gap-4;Compose utilities into existing CSS rule@plugin "@tailwindcss/forms";v4: load an official or third-party plugin@variant dark (&:where(.dark, .dark *));v4: define a custom variant@utility container { ... }v4: define a custom utility@source "../node_modules/my-ui-lib";v4: tell Tailwind to scan additional source@config "./tailwind.config.js";v4: opt in to a JS config filev4 Highlights
CSS-first config (no tailwind.config.js)Configure entirely in CSS via @theme {}@import "tailwindcss"Single import replaces @tailwind base/components/utilitiesOKLCH colour paletteAll default colours use oklch() for wider gamut--color-* / --spacing-* / --font-*Design tokens exposed as CSS custom propertiesstarting-*starting-style utilities for enter transitionsfield-sizing-content / field-sizing-fixedAuto-grow textarea based on contenttext-wrap-balance / text-wrap-prettyBetter text wrapping utilities (now standard)text-shadow-sm / text-shadow / text-shadow-lg / text-shadow-noneBuilt-in text-shadow utilities (previously plugin only)mask-* utilitiesmask-image, mask-size, mask-position, mask-repeat supportinset-shadow-sm / inset-shadow-mdInset shadow as first-class utilitystretch utilities (items-stretch, justify-stretch)Improved stretch support in grid/flexmax-sm: / max-md: / max-lg:Max-width responsive variants built innot-*: variantStyle elements that do NOT match a selectorin-*: variantStyle elements inside a matching ancestornth-* variantsnth-child() and nth-of-type() variantsFaster engine (Rust-based Oxide)Dramatically faster builds compared to v3Automatic content detectionv4 scans source files automatically; no content: [] neededRemoved: bg-opacity-*, text-opacity-*Use colour/opacity modifier syntax instead: bg-blue-500/50Removed: flex-shrink-* / flex-grow-* (v4)Use shrink-* and grow-* instead