devtools logo
by Ryan Macalandag
Back to cheatsheets
Cheatsheetstailwindcssreference

Tailwind Cheatsheet

Quick reference for Tailwind utility classes.

Utility class anatomy

Most Tailwind classes follow the same three-part shape: a property prefix, an optional scale name, and a value.

bg

property — background-color

blue

color scale

500

shade — 50 (lightest) to 950 (darkest)

Example: bg-blue-500

Variants stack in front of the class with a colon, and always apply left to right: sm:hover:bg-blue-600 means "at the sm breakpoint and up, on hover."

Spacing & sizing

Padding, margin, gap, width, and height all share the same numeric scale. Each step is 0.25rem (4px).

Tokenrempx
10.25rem4px
20.5rem8px
41rem16px
61.5rem24px
82rem32px
123rem48px
164rem64px

Flexbox & grid

ClassEffect
flexdisplay: flex
flex-colStack children vertically.
items-centerAlign children on the cross axis.
justify-betweenDistribute children with space between them on the main axis.
flex-1Grow and shrink to fill available space.
grid grid-cols-3Three equal-width columns.
col-span-2Span 2 grid columns.
place-items-centerCenter children both axes in a grid.

Responsive breakpoints

Unprefixed classes apply at every size; a breakpoint prefix applies at that width and above (mobile-first).

PrefixMin width
sm40rem / 640px
md48rem / 768px
lg64rem / 1024px
xl80rem / 1280px
2xl96rem / 1536px
Mobile-first stacking
<div className="flex flex-col gap-4 sm:flex-row sm:items-center">

State variants

VariantApplies when
hover:Pointer is over the element.
focus-visible:Focused via keyboard — prefer this over focus: for outlines.
disabled:Element has the disabled attribute.
data-[state=open]:Matches a data-state="open" attribute — common with Radix/Base UI.
group-hover:Parent with group class is hovered.
peer-invalid:Sibling with peer class is in an invalid state.
first: / last:First or last child among siblings.

Typography

ClassEffect
text-sm / text-base / text-lgFont size scale (0.875rem, 1rem, 1.125rem).
font-medium / font-semibold / font-boldFont weight.
leading-relaxedLine height ~1.625 — good default for body copy.
tracking-tightSlightly reduced letter spacing, common on headings.
truncateSingle-line ellipsis overflow.
text-balance / text-prettyBetter line-wrapping for headings and paragraphs.

Colors

Every color ships in 11 shades (50–950). In this project, prefer the semantic tokens defined in globals.css (bg-background, text-muted-foreground,border-border) over raw palette classes, so theme changes propagate automatically.

Arbitrary values

Square brackets escape to a raw CSS value when the scale doesn't have what you need — use sparingly.

Arbitrary value syntax
<div className="top-[117px] grid-cols-[200px_1fr] bg-[#1da1f2]">

Spot an error or have a suggestion? Open an issue on GitHub.