Skip to content

Tailwind CSS Cheat Sheet

Last verified May 2026 — runs in your browser
Tailwind CSS Cheatsheet
block inline-block inline hidden

Display mode

Layout
flex inline-flex grid

Display flex/grid

Layout
flex-row flex-col flex-wrap

Flex direction and wrap

Layout
items-center items-start items-end

Align items (cross-axis)

Layout
justify-center justify-between justify-around

Justify content (main axis)

Layout
gap-4 gap-x-2 gap-y-6

Gap between flex/grid items

Layout
flex-1 flex-auto flex-none

Flex grow/shrink shortcuts

Layout
grid-cols-3 grid-cols-12

Grid template columns

Layout
col-span-2 col-span-full

Grid column span

Layout
grid-rows-3 row-span-2

Grid rows and row span

Layout
absolute relative fixed sticky

Position

Layout
top-0 right-4 bottom-2 left-auto

Position offsets

Layout
z-10 z-50 z-[9999]

z-index

Layout
overflow-hidden overflow-y-auto

Overflow

Layout
p-4 px-2 py-3 pt-6 pl-8

Padding (all/x/y/individual)

Spacing
m-4 mx-auto my-6 mt-2

Margin

Spacing
-mt-4 -mx-2

Negative margin

Spacing
space-y-4 space-x-2

Space between children

Spacing
w-full w-1/2 w-screen w-[320px]

Width

Spacing
h-full h-screen h-16 h-[100px]

Height

Spacing
min-h-screen min-h-0 max-h-96

Min/max height

Spacing
max-w-md max-w-3xl max-w-prose

Max width presets

Spacing
text-xs text-sm text-base text-lg text-xl text-2xl

Font size scale

Typography
font-thin font-normal font-bold font-black

Font weight

Typography
italic not-italic

Italic style

Typography
text-center text-left text-right text-justify

Text alignment

Typography
underline line-through no-underline

Text decoration

Typography
uppercase lowercase capitalize normal-case

Text transform

Typography
leading-tight leading-normal leading-relaxed

Line height

Typography
tracking-tight tracking-wide

Letter spacing

Typography
truncate text-ellipsis whitespace-nowrap

Truncate overflow text

Typography
font-mono font-sans font-serif

Font family

Typography
text-red-500 text-blue-700 text-gray-900

Text color

Colors
bg-blue-500 bg-white bg-transparent

Background color

Colors
bg-[#1da1f2]

Arbitrary hex color

Colors
bg-gradient-to-r from-pink-500 to-purple-500

Linear gradient

Colors
opacity-50 opacity-0 opacity-100

Opacity

Colors
border border-2 border-0

Border width

Borders
border-t border-b-2 border-l-0

Border on specific side

Borders
border-gray-300 border-blue-500

Border color

Borders
rounded rounded-lg rounded-full rounded-none

Border radius

Borders
rounded-tl-lg rounded-br-2xl

Corner-specific radius

Borders
shadow shadow-md shadow-lg shadow-2xl

Box shadow

Effects
shadow-none ring-2 ring-blue-500

No shadow / ring (focus outline)

Effects
blur backdrop-blur-sm

Blur filters

Effects
hover:bg-blue-600 focus:ring-2

Hover and focus state

States
disabled:opacity-50 disabled:cursor-not-allowed

Disabled state

States
group-hover:text-white peer-focus:border-blue-500

Group/peer states

States
dark:bg-gray-900 dark:text-white

Dark mode variants

States
first:mt-0 last:mb-0 odd:bg-gray-50

Structural variants

States
sm: md: lg: xl: 2xl:

Responsive breakpoint prefixes

Responsive
text-sm md:text-base lg:text-lg

Responsive font size

Responsive
flex-col md:flex-row

Stack mobile, row desktop

Responsive
hidden md:block

Hide on mobile, show on desktop

Responsive
grid-cols-1 sm:grid-cols-2 lg:grid-cols-4

Responsive grid columns

Responsive
cursor-pointer cursor-not-allowed

Cursor style

Interactive
select-none select-text

User select

Interactive
pointer-events-none pointer-events-auto

Pointer events

Interactive
transition transition-all duration-300 ease-in-out

CSS transition

Interactive
transform rotate-45 scale-110 translate-x-2

Transforms

Interactive
animate-spin animate-pulse animate-bounce

Built-in animations

Interactive
Showing 61 of 61 classes

Tailwind CSS Cheat Sheet — Spacing, Flex, Grid, Colors & Responsive Utilities

Tailwind CSS shipped in 2017 with the idea that single-purpose utility classes — `p-4`, `flex`, `text-center` — beat writing custom CSS for the average page; v2.1 introduced arbitrary values like `bg-[#1da1f2]` and the just-in-time engine, which v3 then made the default. The cheatsheet below covers 60+ utility classes across layout, spacing, typography, colors, borders, effects, states, responsive, and interactivity. Most trouble in real Tailwind markup doesn't come from forgetting class names. It comes from quirks that look ordinary but bite. The `space-x-4` utility puts a left margin on every direct child except the first, so wrapping items in an extra flex container silently breaks the spacing. The `dark:` variant only activates when the class strategy is configured — `media` follows the OS preference, `class` waits for a `dark` class on a parent. A class assembled at runtime like `bg-${color}-500` never enters the build, since the purger scans for whole class-name substrings. The snippets below are the ones an author reaches for when debugging exactly that — the right breakpoint, the right variant, the right arbitrary-value escape — without rereading the Tailwind reference from line one each time.

Common pitfalls in Tailwind

A few patterns earn their place on the first screen of any Tailwind project. Responsive prefixes are mobile-first: `text-sm md:text-base` means small text by default and base size from the `md` breakpoint upward, not the other way around. State variants stack with colons: `dark:hover:bg-gray-700` only fires in dark mode and only on hover. Arbitrary values use square brackets and accept any valid CSS value, but spaces need an underscore: `before:content-['Hello_world']` works while a literal space would break the class name. The `@apply` directive composes utilities into a custom class but cannot use variant prefixes like `hover:` or `md:` directly — those need the regular `:hover` or `@media` blocks around the `@apply`. Last-child edges on `space-x-*` and `divide-x-*` can be patched with `last:mr-0` when an extra trailing margin matters. The `safelist` config exists for classes assembled at runtime that the purger would otherwise drop. The cheatsheet groups all of this into Layout, Spacing, Typography, Colors, Borders, Effects, States, Responsive, and Interactive so the right section is one click away.

  • 60+ Tailwind utility classes
  • 9 categories organized by purpose
  • Responsive prefixes (sm, md, lg, xl, 2xl)
  • State variants (hover, focus, dark, group)
  • Flex and Grid utilities
  • One-click copy to clipboard

Free. No signup. Your inputs stay in your browser. Ads via Google AdSense (consent required).

By ·