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)
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).
| Token | rem | px |
|---|---|---|
1 | 0.25rem | 4px |
2 | 0.5rem | 8px |
4 | 1rem | 16px |
6 | 1.5rem | 24px |
8 | 2rem | 32px |
12 | 3rem | 48px |
16 | 4rem | 64px |
gap-* on a flex or grid parent over space-x-* / space-y-* on children — it's more predictable with wrapping and doesn't leak margin onto the last child.Flexbox & grid
| Class | Effect |
|---|---|
flex | display: flex |
flex-col | Stack children vertically. |
items-center | Align children on the cross axis. |
justify-between | Distribute children with space between them on the main axis. |
flex-1 | Grow and shrink to fill available space. |
grid grid-cols-3 | Three equal-width columns. |
col-span-2 | Span 2 grid columns. |
place-items-center | Center 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).
| Prefix | Min width |
|---|---|
sm | 40rem / 640px |
md | 48rem / 768px |
lg | 64rem / 1024px |
xl | 80rem / 1280px |
2xl | 96rem / 1536px |
<div className="flex flex-col gap-4 sm:flex-row sm:items-center">State variants
| Variant | Applies 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
| Class | Effect |
|---|---|
text-sm / text-base / text-lg | Font size scale (0.875rem, 1rem, 1.125rem). |
font-medium / font-semibold / font-bold | Font weight. |
leading-relaxed | Line height ~1.625 — good default for body copy. |
tracking-tight | Slightly reduced letter spacing, common on headings. |
truncate | Single-line ellipsis overflow. |
text-balance / text-pretty | Better 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.
<div className="top-[117px] grid-cols-[200px_1fr] bg-[#1da1f2]">