Tailwind CSS Cheat Sheet

A quick reference guide for common Tailwind CSS utility classes.

Layout

Container

container mx-auto px-4

Display

block | inline-block | inline | flex | grid | hidden | contents

Position

static | relative | absolute | fixed | sticky

Inset

top-0 right-0 bottom-0 left-0
inset-0           /* all four */
inset-x-0  inset-y-0
top-1/2 left-1/2  -translate-x-1/2 -translate-y-1/2

Z-Index

z-0 | z-10 | z-20 | z-50 | z-auto | z-[100]

Overflow

overflow-hidden | overflow-auto | overflow-scroll | overflow-x-auto

Object Fit

object-cover | object-contain | object-center | object-top

Visibility

visible | invisible | collapse

Isolation

isolate | isolation-auto

Flexbox

Direction

flex-row | flex-row-reverse | flex-col | flex-col-reverse

Wrap

flex-wrap | flex-nowrap | flex-wrap-reverse

Justify (main)

justify-start | justify-center | justify-end
justify-between | justify-around | justify-evenly

Align (cross)

items-start | items-center | items-end | items-stretch | items-baseline

Align Content

content-start | content-center | content-between | content-around

Item Sizing

flex-1 | flex-auto | flex-initial | flex-none
basis-1/2 | basis-64
grow | grow-0 | shrink | shrink-0

Order

order-1 | order-first | order-last | -order-1

Self

self-start | self-center | self-end | self-stretch

Gap

gap-4 | gap-x-2 | gap-y-4 | gap-[14px]

Grid

Columns

grid grid-cols-3 | grid-cols-12 | grid-cols-[200px_1fr]

Rows

grid-rows-3 | grid-rows-[auto_1fr_auto]

Span

col-span-2 | col-span-full | row-span-3

Start / End

col-start-2 col-end-4 | row-start-1 row-end-3

Auto Flow

grid-flow-row | grid-flow-col | grid-flow-dense

Auto Sizing

auto-cols-min | auto-cols-max | auto-rows-fr

Place Items

place-items-center | place-content-center | place-self-center

Spacing

Padding

p-4 | px-4 py-2 | pt-0 pr-2 pb-4 pl-1
p-[14px]

Margin

m-4 | mx-auto | my-2 | mb-8 | -mt-4
m-[10px]

Space Between

space-x-4 | space-y-4 | space-x-reverse

Divide

divide-x divide-y | divide-slate-200 | divide-x-2

Sizing

Width

w-4 | w-1/2 | w-full | w-screen | w-fit | w-min | w-max | w-[420px]

Min / Max Width

min-w-0 | min-w-full | min-w-[20rem]
max-w-xs ... max-w-7xl | max-w-screen-xl | max-w-prose

Height

h-4 | h-full | h-screen | h-dvh | h-[480px]

Min / Max Height

min-h-0 | min-h-screen | min-h-dvh
max-h-screen | max-h-[80vh]

Aspect Ratio

aspect-square | aspect-video | aspect-[4/3]

Typography

Font Family

font-sans | font-serif | font-mono

Font Size

text-xs text-sm text-base text-lg
text-xl text-2xl ... text-9xl
text-[15px]

Font Weight

font-thin | font-light | font-normal | font-medium
font-semibold | font-bold | font-extrabold | font-black

Style & Variant

italic | not-italic
uppercase | lowercase | capitalize | normal-case
antialiased | subpixel-antialiased

Color

text-slate-900 | text-blue-500 | text-white
text-[#4f46e5]

Align

text-left | text-center | text-right | text-justify

Leading / Tracking

leading-none | leading-tight | leading-relaxed | leading-[1.7]
tracking-tight | tracking-wide | tracking-[0.2em]

Decoration

underline | line-through | no-underline
decoration-blue-500 | decoration-wavy | decoration-2
underline-offset-4

Truncate

truncate              /* one line */
line-clamp-2          /* multi-line */

Backgrounds

Color

bg-white | bg-slate-900 | bg-blue-500
bg-blue-500/50        /* 50% opacity */
bg-[#4f46e5]

Gradient

bg-gradient-to-r | bg-gradient-to-br | bg-gradient-to-tl
from-blue-500 via-purple-500 to-pink-500

Image

bg-[url("/hero.jpg")]
bg-cover | bg-contain | bg-center | bg-no-repeat | bg-fixed

Borders

Width

border | border-2 | border-4 | border-0
border-x | border-y | border-t | border-b
border-l-2 | border-r-4

Color

border-slate-200 | border-blue-500 | border-transparent

Style

border-solid | border-dashed | border-dotted | border-double | border-none

Radius

rounded | rounded-md | rounded-lg | rounded-xl | rounded-2xl | rounded-full
rounded-t-lg | rounded-tr-2xl | rounded-[14px]

Outline

outline-none | outline | outline-2
outline-blue-500 | outline-offset-2

Ring

ring | ring-2 | ring-4
ring-blue-500 | ring-blue-500/40
ring-offset-2 | ring-inset

Effects

Box Shadow

shadow | shadow-sm | shadow-md | shadow-lg | shadow-xl | shadow-2xl
shadow-none | shadow-inner
shadow-blue-500/20

Opacity

opacity-0 | opacity-50 | opacity-75 | opacity-100

Mix Blend

mix-blend-multiply | mix-blend-overlay | mix-blend-difference

Background Blend

bg-blend-multiply | bg-blend-overlay

Filters

Filter

blur-sm | blur-md | blur-lg | blur-2xl
brightness-50 | brightness-110
contrast-125
grayscale | grayscale-0
saturate-150
hue-rotate-90

Drop Shadow

drop-shadow-sm | drop-shadow-md | drop-shadow-xl

Backdrop

backdrop-blur-md | backdrop-blur-lg
backdrop-brightness-50
backdrop-saturate-150

Transitions

Transition

transition | transition-all | transition-none
transition-colors | transition-opacity | transition-transform

Duration

duration-75 | duration-150 | duration-300 | duration-700 | duration-1000

Easing

ease-linear | ease-in | ease-out | ease-in-out

Delay

delay-100 | delay-300 | delay-500

Animations

Built-in

animate-spin | animate-ping | animate-pulse | animate-bounce | animate-none

Custom (config)

// tailwind.config.js
extend: {
  keyframes: {
    fadeIn: { '0%': {opacity:0}, '100%': {opacity:1} }
  },
  animation: { fadeIn: 'fadeIn 0.5s ease-out' }
}

// Use:
animate-[fadeIn]

Transforms

Scale

scale-50 | scale-100 | scale-110 | scale-150
scale-x-50 | scale-y-110

Rotate

rotate-3 | rotate-45 | rotate-90 | -rotate-12

Translate

translate-x-1 | translate-x-1/2 | translate-x-full
translate-y-2 | -translate-y-4

Skew

skew-x-3 | skew-y-6 | -skew-y-3

Origin

origin-center | origin-top-left | origin-bottom-right

Interactivity

Cursor

cursor-pointer | cursor-not-allowed | cursor-grab | cursor-wait

User Select

select-none | select-text | select-all | select-auto

Pointer Events

pointer-events-none | pointer-events-auto

Resize

resize-none | resize-x | resize-y | resize

Scroll Snap

snap-x snap-mandatory
snap-start | snap-center | snap-end

Caret

caret-blue-500 | accent-blue-500

State Variants

User Action

hover:bg-blue-600
focus:ring-2
active:scale-95
focus-visible:outline-2

Form States

disabled:opacity-50
checked:bg-blue-500
invalid:border-red-500
placeholder:text-slate-400
file:bg-blue-500

Structural

first:rounded-t-lg
last:border-b-0
odd:bg-slate-50
even:bg-white
empty:hidden

Group / Peer

<div class="group">
  <p class="group-hover:text-blue-500">...</p>
</div>

<input class="peer" />
<p class="peer-focus:text-blue-500">...</p>

Responsive

Breakpoints

sm:  ≥ 640px
md:  ≥ 768px
lg:  ≥ 1024px
xl:  ≥ 1280px
2xl: ≥ 1536px

Usage

text-sm md:text-base lg:text-lg
flex-col md:flex-row
hidden lg:block
p-4 sm:p-6 lg:p-10

Max-width queries

max-md:hidden    /* hide ≥ md */
max-lg:p-2       /* below lg */

Dark Mode

Usage

bg-white dark:bg-slate-900
text-slate-900 dark:text-white
border-slate-200 dark:border-slate-800

Config

// tailwind.config.js
darkMode: 'class'   // toggle .dark on <html>
darkMode: 'media'   // follow system

Arbitrary Values

Any Value

w-[420px]
p-[14px]
bg-[#4f46e5]
text-[15px]
grid-cols-[200px_1fr_auto]

CSS Variables

bg-[--brand]
text-[color:var(--text)]

Important

!w-full           /* important variant */

Container Query

@container/sidebar
@md:flex-row
@lg:p-6