🎨 Tailwind CSS
Tailwind CSS Complete Cheatsheet
Typography to grid — complete Tailwind utility class reference with examples.
📖 10 sections
⏱ 18 min read
✅ Quizzes included
🌙 Dark mode
01 Installation & Setup
BASHInstall Tailwind
# With Vite
npm install -D tailwindcss postcss autoprefixer
npx tailwindcss init -p

# tailwind.config.js
module.exports = {
  content: ['./src/**/*.{html,js,jsx,ts,tsx,vue}'],
  theme: { extend: {} },
  plugins: [],
};

# Add to CSS:
@tailwind base;
@tailwind components;
@tailwind utilities;
HTMLBasic usage

Title

💡
Tailwind is utility-first: compose classes instead of writing custom CSS. Use @apply in CSS files to extract repeated patterns.
02 Typography
font-size
text-xs text-sm text-base text-lg text-xl text-2xl text-3xl text-4xl text-5xl text-6xl
font-weight
font-thin font-light font-normal font-medium font-semibold font-bold font-extrabold font-black
font-family
font-sans font-serif font-mono
text-align
text-left text-center text-right text-justify
line-height
leading-none leading-tight leading-snug leading-normal leading-relaxed leading-loose
letter-spacing
tracking-tighter tracking-tight tracking-normal tracking-wide tracking-wider tracking-widest
text-decoration
underline line-through no-underline
text-transform
uppercase lowercase capitalize normal-case
HTMLTypography examples

Heading

Body text

Label
03 Colors & Backgrounds
Text colors
text-{color}-{shade}: text-blue-600 text-red-500 text-gray-900 text-white text-black
Background
bg-{color}-{shade}: bg-white bg-gray-100 bg-blue-500 bg-gradient-to-r from-blue-500 to-purple-600
Opacity
opacity-0 opacity-25 opacity-50 opacity-75 opacity-100 bg-blue-500/50
Gradient
from-{color} via-{color} to-{color} with bg-gradient-to-{direction}
Shades
50 100 200 300 400 500 600 700 800 900 950 (50=lightest, 900=darkest)
Common colors
slate gray zinc neutral stone red orange amber yellow lime green emerald teal cyan sky blue indigo violet purple fuchsia pink rose
HTMLColor examples
04 Spacing
Padding
p-{n} pt- pr- pb- pl- px- py- where n: 0 0.5 1 2 3 4 5 6 7 8 10 12 16 20 24 32 40 48 56 64
Margin
m-{n} mt- mr- mb- ml- mx- my- (same scale). mx-auto = center horizontally
Space between
space-x-{n} space-y-{n} — gap between children (alternative to gap)
Negative margin
-mt-4 -ml-2 — useful for overlapping elements
Scale reference
0=0px, 1=4px, 2=8px, 4=16px, 6=24px, 8=32px, 12=48px, 16=64px, 24=96px
HTMLSpacing examples
-- children spaced 16px apart -->
05 Layout & Flexbox
HTMLFlexbox utilities

flex-direction: row
justify-start | justify-center | justify-end justify-between | justify-around | justify-evenly items-start | items-center | items-end | items-stretch self-start | self-center | self-end flex-1 /* flex: 1 1 0% */ flex-auto /* flex: 1 1 auto */ flex-none /* flex: none */ grow-0 /* flex-grow: 0 */ shrink-0 /* flex-shrink: 0 */ gap-4 gap-x-8 gap-y-4
HTMLCommon flex patterns
06 Grid
HTMLGrid utilities
/* spans 2 columns */
/* spans all columns */
💡
Use 'grid-cols-[repeat(auto-fill,minmax(250px,1fr))]' for responsive grids without breakpoints.
07 Sizing
Width
w-0 w-1 w-2... w-full w-screen w-auto w-1/2 w-1/3 w-2/3 w-1/4 w-3/4 w-fit w-max w-min
Height
h-{n} h-full h-screen h-svh h-auto h-fit
Min/Max
min-w-{n} max-w-{n} min-h-{n} max-h-{n} max-w-sm max-w-md max-w-lg max-w-xl max-w-2xl max-w-7xl
Container
container mx-auto px-4 — responsive fixed-width container
Aspect ratio
aspect-square aspect-video aspect-[4/3]
Overflow
overflow-hidden overflow-auto overflow-scroll overflow-x-auto overflow-y-hidden
HTMLSizing examples
08 Borders & Shadows
Border
border border-{n} border-{color} border-{side} — border-0 border border-2 border-4
Border radius
rounded-none rounded-sm rounded rounded-md rounded-lg rounded-xl rounded-2xl rounded-full
Outline
outline outline-2 outline-offset-2 outline-blue-600 focus:outline-none
Box shadow
shadow-sm shadow shadow-md shadow-lg shadow-xl shadow-2xl shadow-inner shadow-none
Shadow color
shadow-blue-500/50 — colored shadow with opacity
Ring
ring-2 ring-blue-500 ring-offset-2 — focus rings, like outline
HTMLBorder and shadow examples
10 Mini Quizzes
❓ Quiz 1
In Tailwind, what does 'p-4' mean?
Tailwind's spacing scale: 1 unit = 4px. So p-4 = 16px padding all around. p-8 = 32px, p-16 = 64px.
❓ Quiz 2
How do you make a Tailwind style apply only on medium screens and above?
Responsive prefixes: sm: (640px) md: (768px) lg: (1024px) xl: (1280px) 2xl: (1536px). Tailwind is mobile-first — base styles apply to all, prefixed styles override at that breakpoint and above.