AI Workshop: learn to build apps with AI →
Tailwind CSS: The Tailwind Cheat Sheet

Join the AI Workshop and learn to build real-world apps with AI. A hands-on, practical program to level up your skills.


I wrote this cheat sheet because I find myself constantly referencing the Tailwind docs to look up a particular class (I’m starting out and I don’t have muscle memory yet for it)

Here are the things I use the most.

Margin and Padding

Combine those 3 tables. Add a dash before the value (e.g. pt-2, m-auto)

SymbolDescription
pPadding
mMargin
-mNegative margin
SymbolDescription
tTop
rRight
bBottom
lLeft
xHorizontal
yVertical
ValueDescription
00
10.25rem
20.5rem
30.75rem
41rem
51.25rem
61.5rem
82rem
102.5rem
123rem
164rem
205rem
246rem
328rem
px1px
autoauto

margin: 0 auto

I sometimes use margin: 0 auto to center things.

The class mx-auto applies it.

Width

ClassCSS
w-1width: 0.25rem
w-2width: 0.5rem
w-3width: 0.75rem
w-4width: 1rem
w-6width: 1.5rem
w-8width: 2rem
w-10width: 2.5rem
w-12width: 3rem
w-16width: 4rem
w-24width: 6rem
w-32width: 8rem
w-48width: 12rem
w-64width: 16rem
w-autowidth: auto
w-pxwidth: 1px
w-1/2width: 50%
w-1/3width: 33.33333%
w-2/3width: 66.66667%
w-1/4width: 25%
w-3/4width: 75%
w-1/5width: 20%
w-2/5width: 40%
w-3/5width: 60%
w-4/5width: 80%
w-1/6width: 16.66667%
w-5/6width: 83.33333%
w-fullwidth: 100%
w-screenwidth: 100vw

Max Width

ClassCSS
max-w-xsmax-width: 20rem
max-w-smmax-width: 24rem
max-w-mdmax-width: 28rem
max-w-lgmax-width: 32rem
max-w-xlmax-width: 36rem
max-w-2xlmax-width: 42rem
max-w-3xlmax-width: 48rem
max-w-4xlmax-width: 56rem
max-w-5xlmax-width: 64rem
max-w-6xlmax-width: 72rem
max-w-7xlmax-width: 80rem
max-w-fullmax-width: 100%

Min width

ClassCSS
min-w-0min-width: 0
min-w-fullmin-width: 100%

Font Family

ClassCSS
font-sansfont-family: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
font-seriffont-family: ui-serif, Georgia, Cambria, "Times New Roman", Times, serif;
font-monofont-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;

Font Size

ClassCSS
text-xsfont-size: .75rem
text-smfont-size: .875rem
text-basefont-size: 1rem
text-lgfont-size: 1.125rem
text-xlfont-size: 1.25rem
text-2xlfont-size: 1.5rem
text-3xlfont-size: 1.875rem
text-4xlfont-size: 2.25rem
text-5xlfont-size: 3rem
text-6xlfont-size: 3.75rem
text-7xlfont-size: 4.5rem
text-8xlfont-size: 6rem
text-9xlfont-size: 8rem

Font weight

ClassCSS
font-thinfont-weight: 100
font-extralightfont-weight: 200
font-lightfont-weight: 300
font-normalfont-weight: 400
font-mediumfont-weight: 500
font-semiboldfont-weight: 600
font-boldfont-weight: 700
font-extraboldfont-weight: 800
font-blackfont-weight: 900

Colors

Tailwind provides these color names:

  • slate, gray, zinc, neutral, stone
  • red, orange, amber, yellow, lime, green, emerald
  • teal, cyan, sky, blue, indigo, violet, purple, fuchsia, pink, rose

Each color has various levels you can use:

  • 50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950

Example:

  • fuchsia-50
  • fuchsia-500
  • fuchsia-950

We also have transparent, black and white, which do not have levels.

Text color

To apply a color to text, prepend text- to any color (example: text-red-500).

Background color

To apply a background color, prepend bg- to any color (example: bg-green-600).

Center text

Use text-center to center text.

Line Height

ClassCSS
.leading-noneline-height: 1
.leading-tightline-height: 1.25
.leading-snugline-height: 1.375
.leading-normalline-height: 1.5
.leading-relaxedline-height: 1.625
.leading-looseline-height: 2

You can also use numbers, from .leading-3 to .leading-10

Lessons in this unit:

0: Introduction
1: Box model properties
2: Colors
3: Typography
4: Flexbox and Grid in Tailwind
5: Modifiers
6: Responsive design in Tailwind
7: Apply a style to children with Tailwind
8: How to fix Unknown at rule @tailwindcss (unknownAtRules) in VS Code
9: How to align center vertically using Tailwind
10: How to use custom fonts with Tailwind CSS
11: Setting up Tailwind CSS on Vite
12: Show-hide an element based on existence of a parent class in Tailwind
13: ▶︎ The Tailwind Cheat Sheet
14: How to set up Tailwind CSS (v4)
15: You can’t generate classes dynamically in Tailwind