← Home

Tailwind CSS Classes Cheatsheet

Complete Tailwind CSS utility class reference — spacing, typography, colors, layout, flexbox, grid, borders, effects, and responsive breakpoints.

Spacing

p-{n}Padding on all sides. Values: 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, 96, px, auto
px-{n} / py-{n}Padding horizontal (left + right) / vertical (top + bottom)
pt-{n} / pr-{n} / pb-{n} / pl-{n}Padding on individual sides (top, right, bottom, left)
m-{n}Margin on all sides. Same scale as padding. Supports negative values: -m-4
mx-{n} / my-{n}Margin horizontal / vertical. mx-auto centers a block element
mt-{n} / mr-{n} / mb-{n} / ml-{n}Margin on individual sides
gap-{n}Gap between flex/grid children. gap-x-{n} and gap-y-{n} for axis-specific
space-x-{n}Horizontal space between children (adds margin-left to all but first)
space-y-{n}Vertical space between children (adds margin-top to all but first)

Typography

text-xsFont size 0.75rem (12px) with line-height 1rem (16px)
text-smFont size 0.875rem (14px) with line-height 1.25rem (20px)
text-baseFont size 1rem (16px) with line-height 1.5rem (24px)
text-lgFont size 1.125rem (18px) with line-height 1.75rem (28px)
text-xl / text-2xl / text-3xl1.25rem / 1.5rem / 1.875rem. Up to text-9xl (8rem)
text-4xl / text-5xl / text-6xl2.25rem / 3rem / 3.75rem with tight line-height
text-7xl / text-8xl / text-9xl4.5rem / 6rem / 8rem for display headings
font-thin / font-light / font-normalFont weight 100 / 300 / 400
font-medium / font-semibold / font-boldFont weight 500 / 600 / 700
font-extrabold / font-blackFont weight 800 / 900
font-sans / font-serif / font-monoFont family: system sans-serif / serif / monospace
leading-none / leading-tight / leading-snugLine-height: 1 / 1.25 / 1.375
leading-normal / leading-relaxed / leading-looseLine-height: 1.5 / 1.625 / 2
tracking-tighter / tracking-tight / tracking-normalLetter-spacing: -0.05em / -0.025em / 0em
tracking-wide / tracking-wider / tracking-widestLetter-spacing: 0.025em / 0.05em / 0.1em
text-left / text-center / text-right / text-justifyText alignment
uppercase / lowercase / capitalize / normal-caseText transform
truncateOverflow hidden + text ellipsis + whitespace nowrap
line-clamp-{n}Truncate text after n lines with ellipsis (1–6)

Colors

text-{color}-{shade}Text color. Colors: slate, gray, zinc, neutral, stone, red, orange, amber, yellow, lime, green, emerald, teal, cyan, sky, blue, indigo, violet, purple, fuchsia, pink, rose
text-white / text-black / text-transparentSpecial text color values
text-inherit / text-currentInherit from parent / use currentColor
bg-{color}-{shade}Background color. Shades: 50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950
bg-white / bg-black / bg-transparentSpecial background color values
bg-gradient-to-{dir}Gradient direction: t, tr, r, br, b, bl, l, tl
from-{color}-{shade} / via-{color}-{shade} / to-{color}-{shade}Gradient color stops
border-{color}-{shade}Border color with same color palette and shades
ring-{color}-{shade}Box-shadow ring color
placeholder-{color}-{shade}Placeholder text color
text-{color}-{shade}/{opacity}Color with opacity modifier, e.g., text-blue-500/50 for 50% opacity

Layout

block / inline-block / inlineDisplay: block / inline-block / inline
flex / inline-flexDisplay: flex / inline-flex
grid / inline-gridDisplay: grid / inline-grid
hiddenDisplay: none — completely hides the element
containerSets max-width to current breakpoint. Centers with mx-auto
w-{n} / w-full / w-screen / w-autoWidth: fixed value / 100% / 100vw / auto. Also w-1/2, w-1/3, w-2/3, etc.
h-{n} / h-full / h-screen / h-autoHeight: fixed value / 100% / 100vh / auto
min-w-0 / min-w-full / min-w-min / min-w-maxMinimum width constraints
max-w-xs / max-w-sm / max-w-md / max-w-lg / max-w-xlMax-width: 20rem / 24rem / 28rem / 32rem / 36rem
max-w-2xl / max-w-3xl / max-w-4xl / max-w-5xl / max-w-6xl / max-w-7xlMax-width: 42rem → 80rem
max-w-full / max-w-screen-sm / max-w-screen-md / max-w-screen-lgMax-width: 100% / breakpoint-sized
min-h-0 / min-h-full / min-h-screenMinimum height: 0 / 100% / 100vh
overflow-hidden / overflow-auto / overflow-scroll / overflow-visibleOverflow behavior
relative / absolute / fixed / stickyPosition type
top-{n} / right-{n} / bottom-{n} / left-{n}Position offset (use with absolute/fixed/sticky)
z-0 / z-10 / z-20 / z-30 / z-40 / z-50 / z-autoZ-index stacking order

Flexbox

flex-row / flex-row-reverseFlex direction: horizontal (default) / reversed
flex-col / flex-col-reverseFlex direction: vertical / reversed vertical
flex-wrap / flex-wrap-reverse / flex-nowrapWhether flex items wrap to new lines
justify-start / justify-end / justify-centerMain-axis alignment: start / end / center
justify-between / justify-around / justify-evenlyMain-axis: space-between / space-around / space-evenly
items-start / items-end / items-centerCross-axis alignment: start / end / center
items-baseline / items-stretchCross-axis: baseline alignment / stretch to fill
flex-1flex: 1 1 0% — grow and shrink, ignoring initial size
flex-autoflex: 1 1 auto — grow and shrink, considering initial size
flex-initialflex: 0 1 auto — shrink but don't grow (default)
flex-noneflex: none — don't grow or shrink
flex-grow / flex-grow-0Allow item to grow / prevent growing
flex-shrink / flex-shrink-0Allow item to shrink / prevent shrinking
order-{n} / order-first / order-last / order-noneVisual order of flex items
self-auto / self-start / self-end / self-center / self-stretchOverride align-items for individual item
gap-{n}Gap between flex children (same as grid gap)

Grid

grid-cols-{n}Define grid columns (1–12). grid-cols-3 = 3 equal columns
grid-cols-noneNo explicit column template
grid-rows-{n}Define grid rows (1–6). grid-rows-3 = 3 equal rows
grid-rows-noneNo explicit row template
col-span-{n}Span n columns (1–12). col-span-full spans all columns
col-start-{n} / col-end-{n}Set column start/end line (1–13)
row-span-{n}Span n rows (1–6). row-span-full spans all rows
row-start-{n} / row-end-{n}Set row start/end line (1–7)
gap-{n} / gap-x-{n} / gap-y-{n}Grid gap (all / column / row)
auto-cols-auto / auto-cols-min / auto-cols-max / auto-cols-frSize of implicitly-created columns
auto-rows-auto / auto-rows-min / auto-rows-max / auto-rows-frSize of implicitly-created rows
grid-flow-row / grid-flow-col / grid-flow-denseHow auto-placed items flow in the grid
place-content-center / place-items-centerShorthand to center grid content/items on both axes

Borders & Rounded

border / border-0 / border-2 / border-4 / border-8Border width: 1px / 0 / 2px / 4px / 8px
border-t / border-r / border-b / border-lBorder on individual sides (default 1px)
border-t-2 / border-r-4 / border-b-8Specific border width per side
border-solid / border-dashed / border-dotted / border-double / border-noneBorder style
rounded / rounded-md / rounded-lg / rounded-xl / rounded-2xl / rounded-3xlBorder radius: 0.25rem → 1.5rem
rounded-none / rounded-smNo radius / 0.125rem
rounded-fullBorder radius 9999px — fully rounded (circles/pills)
rounded-t-{size} / rounded-b-{size} / rounded-l-{size} / rounded-r-{size}Radius on specific sides
divide-x / divide-yAdd borders between children (horizontal / vertical)
divide-x-2 / divide-y-2Thicker dividers between children (2px)
divide-{color}-{shade}Divider color
ring-0 / ring-1 / ring-2 / ring / ring-4 / ring-8Box-shadow ring width
ring-insetMove ring to inside the element
ring-offset-{n}Add gap between element and ring (1, 2, 4, 8)
outline-none / outline / outline-dashed / outline-dottedOutline style (useful for focus states)

Effects & Transitions

shadow-sm / shadow / shadow-md / shadow-lg / shadow-xl / shadow-2xlBox shadow size (smallest to largest)
shadow-inner / shadow-noneInner shadow / no shadow
opacity-0 / opacity-25 / opacity-50 / opacity-75 / opacity-100Element opacity (0%–100%)
blur-sm / blur / blur-md / blur-lg / blur-xl / blur-2xl / blur-3xlBlur filter
brightness-{n} / contrast-{n} / saturate-{n}Filter adjustments: 0, 50, 75, 90, 95, 100, 105, 110, 125, 150, 200
backdrop-blur-{size}Blur behind element (for frosted glass effect)
transitionTransition: color, background, border, text-decoration, fill, stroke, opacity, shadow, transform, filter
transition-colors / transition-opacity / transition-transform / transition-allSpecific transition properties
duration-75 / duration-100 / duration-150 / duration-200 / duration-300 / duration-500 / duration-700 / duration-1000Transition duration in ms
ease-linear / ease-in / ease-out / ease-in-outTransition timing function
delay-75 / delay-100 / delay-150 / delay-200 / delay-300 / delay-500 / delay-700 / delay-1000Transition delay in ms
hover:{utility}Apply utility on hover (e.g., hover:bg-blue-600)
focus:{utility}Apply utility on focus (e.g., focus:ring-2)
active:{utility}Apply utility on active/pressed state
dark:{utility}Apply utility in dark mode (e.g., dark:bg-gray-900)
group-hover:{utility}Apply when parent .group is hovered

Responsive Breakpoints

sm:{utility}@media (min-width: 640px) — Small screens and up
md:{utility}@media (min-width: 768px) — Medium screens and up
lg:{utility}@media (min-width: 1024px) — Large screens and up
xl:{utility}@media (min-width: 1280px) — Extra-large screens and up
2xl:{utility}@media (min-width: 1536px) — 2x extra-large screens and up
max-sm:{utility}@media (max-width: 639px) — Below small breakpoint only
max-md:{utility}@media (max-width: 767px) — Below medium breakpoint only
max-lg:{utility}@media (max-width: 1023px) — Below large breakpoint only
Mobile-first pattern: w-full md:w-1/2 lg:w-1/3Full width on mobile, half on medium, third on large
Stacking: flex flex-col md:flex-rowColumn layout on mobile, row on medium+
Visibility: hidden md:blockHidden on mobile, visible from medium up
Typography: text-sm md:text-base lg:text-lgResponsive font sizes across breakpoints

Frequently Asked Questions

What is the difference between p-4 and px-4 in Tailwind?

p-4 adds 1rem (16px) padding on all four sides. px-4 adds 1rem padding only on the left and right (horizontal). Similarly, py-4 applies to top and bottom (vertical). You can also use pt-, pr-, pb-, pl- for individual sides.

How does Tailwind's responsive design system work?

Tailwind uses a mobile-first approach with min-width breakpoints. Unprefixed utilities apply to all screen sizes. Prefixed utilities like md:flex only apply at that breakpoint and above. For example, 'hidden md:block' hides an element on mobile and shows it on screens ≥768px.

Can I use custom values not in Tailwind's default scale?

Yes. Use arbitrary values with square bracket notation, e.g., w-[137px], text-[#1da1f2], grid-cols-[200px_1fr_200px]. You can also extend the theme in tailwind.config.js to add custom values to any utility scale.

What is the difference between gap, space-x, and divide?

gap-{n} uses CSS gap (works with flex and grid). space-x-{n} adds margin-left to all children except the first (flex only, breaks with flex-wrap). divide-x adds border-left between children. For modern layouts, gap is generally preferred.

Related Resources