Tailwind CSS Cheatsheet - Utility Class Reference

Essential Tailwind CSS utility classes for atomic CSS, organized by function from layout to colors, responsive design to animations. Copy directly when building pages.

Web Services·61 commands·Last updated 2026-07-21
Back to Web Services

Layout 7

container
Responsive container, auto-centered with max-width
block / inline-block / inline
Display types
hidden
Hide element (display: none)
relative / absolute / fixed / sticky
Positioning
overflow-auto / overflow-hidden
Overflow handling
visible / invisible
Visibility control
z-10 / z-50 / z-[-1]
Z-index stacking order

Flexbox 7

flex
Enable flexbox layout
flex-row / flex-col
Flex direction (row/column)
flex-wrap / flex-nowrap
Wrap behavior
justify-start / justify-center / justify-between / justify-end
Main axis alignment
items-start / items-center / items-end
Cross axis alignment
flex-1 / flex-auto / flex-none
Flex grow/shrink
gap-4 / gap-x-4 / gap-y-4
Gap between items

Grid 7

grid
Enable grid layout
grid-cols-3 / grid-cols-12
Define column count
grid-rows-3
Define row count
col-span-2 / col-span-full
Column spanning
row-span-2 / row-span-full
Row spanning
place-items-center / place-content-center
Grid alignment
gap-4
Grid gap

Spacing & Sizing 8

p-4 / px-4 / py-2 / pt-4
Padding
m-4 / mx-auto / my-2 / mt-4
Margin (mx-auto for horizontal centering)
space-x-4 / space-y-4
Child spacing
w-64 / w-1/2 / w-full / w-screen
Width
h-64 / h-1/2 / h-full / h-screen
Height
max-w-lg / max-w-7xl / max-w-screen-xl
Max width
min-h-screen / min-h-0
Min height
size-8 / size-16
Width and height together (Tailwind 3.4+)

Typography 9

text-xs / text-sm / text-base / text-lg / text-xl / text-2xl ... text-9xl
Font size
font-thin / font-normal / font-medium / font-bold / font-black
Font weight
leading-none / leading-tight / leading-relaxed / leading-loose
Line height
tracking-tight / tracking-wide / tracking-wider
Letter spacing
text-left / text-center / text-right / text-justify
Text alignment
underline / line-through / no-underline
Text decoration
uppercase / lowercase / capitalize
Text transform
truncate
Text overflow ellipsis (single line)
whitespace-nowrap / break-words
Whitespace handling

Colors & Background 7

text-red-500 / text-blue-600 / text-gray-900
Text color (50-900 scale)
bg-white / bg-gray-100 / bg-blue-500
Background color
border-gray-300 / border-red-500
Border color
ring-2 ring-blue-500
Ring color and width (focus indicator)
shadow-sm / shadow-md / shadow-lg / shadow-xl
Box shadow
opacity-50 / opacity-100
Opacity
bg-gradient-to-r from-blue-500 to-purple-500
Gradient background

Responsive & Interaction 9

sm: / md: / lg: / xl: / 2xl:
Responsive breakpoint prefixes (mobile-first)
hover:bg-blue-500
Hover state
focus:outline-none focus:ring-2
Focus state
active:scale-95
Active/click state
dark:bg-gray-800 dark:text-white
Dark mode
transition / transition-all / transition-colors
Transition animation
hover:scale-110 / hover:rotate-6
Transform animation
animate-spin / animate-ping / animate-pulse / animate-bounce
Built-in animations
cursor-pointer / cursor-not-allowed
Cursor style

Border & Effects 7

border / border-2 / border-4 / border-b-2
Border width
border-solid / border-dashed / border-dotted / border-none
Border style
rounded-sm / rounded / rounded-lg / rounded-xl / rounded-full
Border radius
ring / ring-2 ring-inset
Ring outline for focus states
shadow / shadow-md / shadow-lg / shadow-xl / shadow-2xl
Shadow size
outline / outline-2 outline-offset-2
Outline
blur-sm / blur-lg / brightness-50 / contrast-125 / grayscale
Filter effects

💡 Tips

  • Tailwind uses mobile-first responsive design: sm: ≥640px, md: ≥768px, lg: ≥1024px
  • Use dark: prefix for dark mode, e.g. dark:bg-gray-800
  • Use @apply directive to reuse Tailwind classes in CSS
  • Common color scales: 50/100/200/300/400/500/600/700/800/900, higher = darker
  • JIT mode only compiles classes you actually use, resulting in minimal CSS