Tailwind CSS Cheatsheet

Every Tailwind CSS utility class in one reference page. Organized by category with the CSS each class produces. Bookmark this page and stop guessing class names.

Spacing Scale

The spacing scale is shared by padding, margin, gap, width, height, and inset utilities. Combine any prefix below with a scale value.

Prefixes

PrefixCSS Property
p-{n}padding
px-{n}padding-left & padding-right
py-{n}padding-top & padding-bottom
pt-{n}padding-top
pr-{n}padding-right
pb-{n}padding-bottom
pl-{n}padding-left
m-{n}margin
mx-{n}margin-left & margin-right
my-{n}margin-top & margin-bottom
mt-{n}margin-top
mr-{n}margin-right
mb-{n}margin-bottom
ml-{n}margin-left
space-x-{n}horizontal gap between children (margin-left)
space-y-{n}vertical gap between children (margin-top)
gap-{n}gap (flex/grid)
gap-x-{n}column-gap
gap-y-{n}row-gap

Scale Values

ValueSize
00px
px1px
0.50.125rem (2px)
10.25rem (4px)
1.50.375rem (6px)
20.5rem (8px)
2.50.625rem (10px)
30.75rem (12px)
3.50.875rem (14px)
41rem (16px)
51.25rem (20px)
61.5rem (24px)
71.75rem (28px)
82rem (32px)
92.25rem (36px)
102.5rem (40px)
112.75rem (44px)
123rem (48px)
143.5rem (56px)
164rem (64px)
205rem (80px)
246rem (96px)
287rem (112px)
328rem (128px)
369rem (144px)
4010rem (160px)
4411rem (176px)
4812rem (192px)
5213rem (208px)
5614rem (224px)
6015rem (240px)
6416rem (256px)
7218rem (288px)
8020rem (320px)
9624rem (384px)

Typography

Font Size

Classfont-size / line-height
text-xs0.75rem / 1rem (12px)
text-sm0.875rem / 1.25rem (14px)
text-base1rem / 1.5rem (16px)
text-lg1.125rem / 1.75rem (18px)
text-xl1.25rem / 1.75rem (20px)
text-2xl1.5rem / 2rem (24px)
text-3xl1.875rem / 2.25rem (30px)
text-4xl2.25rem / 2.5rem (36px)
text-5xl3rem / 1 (48px)
text-6xl3.75rem / 1 (60px)
text-7xl4.5rem / 1 (72px)
text-8xl6rem / 1 (96px)
text-9xl8rem / 1 (128px)

Font Weight

ClassValue / Description
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

Text Utilities

ClassValue / Description
italicfont-style: italic
not-italicfont-style: normal
uppercasetext-transform: uppercase
lowercasetext-transform: lowercase
capitalizetext-transform: capitalize
normal-casetext-transform: none
underlinetext-decoration: underline
overlinetext-decoration: overline
line-throughtext-decoration: line-through
no-underlinetext-decoration: none
truncateoverflow: hidden + text-overflow: ellipsis + white-space: nowrap
text-lefttext-align: left
text-centertext-align: center
text-righttext-align: right
text-justifytext-align: justify
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
tracking-tighterletter-spacing: -0.05em
tracking-tightletter-spacing: -0.025em
tracking-normalletter-spacing: 0em
tracking-wideletter-spacing: 0.025em
tracking-widerletter-spacing: 0.05em
tracking-widestletter-spacing: 0.1em
font-sansfont-family: system sans-serif stack
font-seriffont-family: serif stack
font-monofont-family: monospace stack
antialiased-webkit-font-smoothing: antialiased
subpixel-antialiased-webkit-font-smoothing: auto

Colors

Tailwind ships with a curated color palette. Apply colors with a prefix, color name, and shade.

Color Prefixes

PatternApplies to
text-{color}-{shade}Text color
bg-{color}-{shade}Background color
border-{color}-{shade}Border color
ring-{color}-{shade}Ring (outline) color
divide-{color}-{shade}Divider color between children
placeholder-{color}-{shade}Placeholder text color
accent-{color}-{shade}Accent color for form controls
decoration-{color}-{shade}Text decoration color
shadow-{color}-{shade}Box shadow color
outline-{color}-{shade}Outline color
fill-{color}-{shade}SVG fill color
stroke-{color}-{shade}SVG stroke color

Color Names

slategrayzincneutralstoneredorangeamberyellowlimegreenemeraldtealcyanskyblueindigovioletpurplefuchsiapinkrose

Shade Scale

50100200300400500600700800900950

Special Colors

  • inherit — inherits from parent
  • current — currentColor
  • transparent — transparent
  • black / white — #000 / #fff
  • Arbitrary values: text-[#1a2b3c] or bg-[rgb(255,0,0)]

Sizing (Width & Height)

ClassValue / Description
w-{spacing}Width using the spacing scale (0-96)
w-autowidth: auto
w-fullwidth: 100%
w-screenwidth: 100vw
w-svwwidth: 100svw
w-minwidth: min-content
w-maxwidth: max-content
w-fitwidth: fit-content
w-1/2, w-1/3, ...Fractional widths (1/2 through 11/12)
min-w-0min-width: 0px
min-w-fullmin-width: 100%
min-w-min / max / fitmin-width: min-content / max-content / fit-content
max-w-xsmax-width: 20rem (320px)
max-w-smmax-width: 24rem (384px)
max-w-mdmax-width: 28rem (448px)
max-w-lgmax-width: 32rem (512px)
max-w-xlmax-width: 36rem (576px)
max-w-2xlmax-width: 42rem (672px)
max-w-3xlmax-width: 48rem (768px)
max-w-4xlmax-width: 56rem (896px)
max-w-5xlmax-width: 64rem (1024px)
max-w-6xlmax-width: 72rem (1152px)
max-w-7xlmax-width: 80rem (1280px)
max-w-fullmax-width: 100%
max-w-prosemax-width: 65ch
max-w-screen-sm / md / lg / xl / 2xlmax-width at breakpoint widths
max-w-nonemax-width: none
h-{spacing}Height using the spacing scale
h-autoheight: auto
h-fullheight: 100%
h-screenheight: 100vh
h-svhheight: 100svh
h-dvhheight: 100dvh
h-min / max / fitheight: min-content / max-content / fit-content
min-h-0 / full / screen / svh / dvh / min / max / fitmin-height variants
max-h-{spacing}max-height using the spacing scale
max-h-full / screen / svh / dvh / min / max / fit / nonemax-height variants
size-{spacing}Sets both width and height to the same value

Display & Position

Display

ClassValue / Description
blockdisplay: block
inline-blockdisplay: inline-block
inlinedisplay: inline
flexdisplay: flex
inline-flexdisplay: inline-flex
griddisplay: grid
inline-griddisplay: inline-grid
tabledisplay: table
hiddendisplay: none
contentsdisplay: contents
flow-rootdisplay: flow-root

Position

ClassValue / Description
staticposition: static
fixedposition: fixed
absoluteposition: absolute
relativeposition: relative
stickyposition: sticky
inset-0top/right/bottom/left: 0px
inset-x-0left: 0; right: 0
inset-y-0top: 0; bottom: 0
top-{n} / right-{n} / bottom-{n} / left-{n}Position offsets (spacing scale)
z-0 / 10 / 20 / 30 / 40 / 50 / autoz-index values

Flexbox

Flex Container & Items

ClassValue / Description
flexdisplay: flex
inline-flexdisplay: inline-flex
flex-rowflex-direction: row (default)
flex-row-reverseflex-direction: row-reverse
flex-colflex-direction: column
flex-col-reverseflex-direction: column-reverse
flex-wrapflex-wrap: wrap
flex-wrap-reverseflex-wrap: wrap-reverse
flex-nowrapflex-wrap: nowrap
flex-1flex: 1 1 0% — grow and shrink, ignore initial size
flex-autoflex: 1 1 auto — grow and shrink, based on initial size
flex-initialflex: 0 1 auto — shrink but don't grow
flex-noneflex: none — don't grow or shrink
growflex-grow: 1
grow-0flex-grow: 0
shrinkflex-shrink: 1
shrink-0flex-shrink: 0
basis-{size}flex-basis (accepts spacing scale or fractions)
order-{n}order: {n} (1-12, first, last, none)

Alignment & Justification

ClassValue / Description
justify-startjustify-content: flex-start
justify-endjustify-content: flex-end
justify-centerjustify-content: center
justify-betweenjustify-content: space-between
justify-aroundjustify-content: space-around
justify-evenlyjustify-content: space-evenly
items-startalign-items: flex-start
items-endalign-items: flex-end
items-centeralign-items: center
items-baselinealign-items: baseline
items-stretchalign-items: stretch
self-autoalign-self: auto
self-startalign-self: flex-start
self-endalign-self: flex-end
self-centeralign-self: center
self-stretchalign-self: stretch
content-startalign-content: flex-start
content-endalign-content: flex-end
content-centeralign-content: center
content-betweenalign-content: space-between
content-aroundalign-content: space-around
content-evenlyalign-content: space-evenly

Grid

ClassValue / Description
griddisplay: grid
inline-griddisplay: inline-grid
grid-cols-{n}grid-template-columns: repeat(n, minmax(0, 1fr)) — 1 to 12
grid-cols-nonegrid-template-columns: none
grid-cols-subgridgrid-template-columns: subgrid
grid-rows-{n}grid-template-rows: repeat(n, minmax(0, 1fr)) — 1 to 12
grid-rows-nonegrid-template-rows: none
col-span-{n}grid-column: span n / span n — 1 to 12
col-span-fullgrid-column: 1 / -1
col-start-{n}grid-column-start: n — 1 to 13
col-end-{n}grid-column-end: n — 1 to 13
row-span-{n}grid-row: span n / span n — 1 to 12
row-span-fullgrid-row: 1 / -1
row-start-{n}grid-row-start: n — 1 to 13
row-end-{n}grid-row-end: n — 1 to 13
grid-flow-rowgrid-auto-flow: row
grid-flow-colgrid-auto-flow: column
grid-flow-densegrid-auto-flow: dense
grid-flow-row-densegrid-auto-flow: row dense
grid-flow-col-densegrid-auto-flow: column dense
auto-cols-autogrid-auto-columns: auto
auto-cols-mingrid-auto-columns: min-content
auto-cols-maxgrid-auto-columns: max-content
auto-cols-frgrid-auto-columns: minmax(0, 1fr)
auto-rows-autogrid-auto-rows: auto
auto-rows-mingrid-auto-rows: min-content
auto-rows-maxgrid-auto-rows: max-content
auto-rows-frgrid-auto-rows: minmax(0, 1fr)
place-content-centerplace-content: center
place-items-centerplace-items: center
place-self-centerplace-self: center

Borders & Rings

ClassValue / Description
borderborder-width: 1px
border-0border-width: 0px
border-2border-width: 2px
border-4border-width: 4px
border-8border-width: 8px
border-t / r / b / lBorder on one side only (1px)
border-t-{n}Border on one side: 0, 2, 4, 8
border-solidborder-style: solid
border-dashedborder-style: dashed
border-dottedborder-style: dotted
border-doubleborder-style: double
border-hiddenborder-style: hidden
border-noneborder-style: none
rounded-noneborder-radius: 0px
rounded-smborder-radius: 0.125rem (2px)
roundedborder-radius: 0.25rem (4px)
rounded-mdborder-radius: 0.375rem (6px)
rounded-lgborder-radius: 0.5rem (8px)
rounded-xlborder-radius: 0.75rem (12px)
rounded-2xlborder-radius: 1rem (16px)
rounded-3xlborder-radius: 1.5rem (24px)
rounded-fullborder-radius: 9999px
rounded-t / r / b / lBorder radius on one side
rounded-tl / tr / br / blBorder radius on one corner
divide-xVertical dividers between horizontal children
divide-yHorizontal dividers between stacked children
divide-x-{n}Divider width: 0, 2, 4, 8, reverse
ring-{n}Box shadow ring: 0, 1, 2, 4, 8 (default 3)
ring-insetRing rendered inside the element
ring-offset-{n}Gap between ring and element: 0, 1, 2, 4, 8
outline-{n}Outline width: 0, 1, 2, 4, 8
outline-offset-{n}Outline offset: 0, 1, 2, 4, 8

Shadows

ClassValue / Description
shadow-smSmall shadow
shadowDefault shadow
shadow-mdMedium shadow
shadow-lgLarge shadow
shadow-xlExtra-large shadow
shadow-2xlHuge shadow
shadow-innerInner (inset) shadow
shadow-noneNo shadow
drop-shadow-smSmall drop shadow (filter)
drop-shadowDefault drop shadow (filter)
drop-shadow-mdMedium drop shadow (filter)
drop-shadow-lgLarge drop shadow (filter)
drop-shadow-xlExtra-large drop shadow (filter)
drop-shadow-2xlHuge drop shadow (filter)
drop-shadow-noneNo drop shadow

Responsive Breakpoints

Tailwind is mobile-first. Unprefixed utilities target all screen sizes. Use breakpoint prefixes to apply styles at that width and above.

PrefixMin WidthCSS
sm:640px@media (min-width: 640px)
md:768px@media (min-width: 768px)
lg:1024px@media (min-width: 1024px)
xl:1280px@media (min-width: 1280px)
2xl:1536px@media (min-width: 1536px)

Example

<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3">
1 column on mobile, 2 on medium screens, 3 on large screens.

Dark Mode & State Modifiers

Prefix any utility with a modifier to apply it conditionally. Multiple modifiers can be stacked: dark:hover:bg-gray-700.

ModifierCondition
hover:On mouse hover
focus:On focus
focus-within:When a child has focus
focus-visible:On keyboard focus (not mouse)
active:While being pressed
visited:Visited link
disabled:Disabled form element
checked:Checked checkbox/radio
first:First child
last:Last child
odd:Odd children
even:Even children
group-hover:When a parent with class 'group' is hovered
peer-focus:When a sibling with class 'peer' is focused
dark:Dark mode (prefers-color-scheme: dark or class strategy)
motion-safe:prefers-reduced-motion: no-preference
motion-reduce:prefers-reduced-motion: reduce
print:@media print
portrait:@media (orientation: portrait)
landscape:@media (orientation: landscape)
placeholder:Style placeholder text
selection:Style selected text
before:::before pseudo-element (add content-[''])
after:::after pseudo-element (add content-[''])
file:Style file input button
marker:Style list markers
first-line:::first-line pseudo-element
first-letter:::first-letter pseudo-element

Dark Mode Example

<div class="bg-white dark:bg-gray-900 text-gray-900 dark:text-gray-100">
Light background and dark text by default; inverted in dark mode.

Transitions & Animation

ClassValue / Description
transition-noneNo transition
transition-allTransition all properties
transitionTransition color, bg, border, shadow, opacity, transform, filter
transition-colorsTransition color properties only
transition-opacityTransition opacity only
transition-shadowTransition shadow only
transition-transformTransition transform only
duration-{n}Duration: 0, 75, 100, 150, 200, 300, 500, 700, 1000 (ms)
ease-lineartiming-function: linear
ease-intiming-function: cubic-bezier(0.4, 0, 1, 1)
ease-outtiming-function: cubic-bezier(0, 0, 0.2, 1)
ease-in-outtiming-function: cubic-bezier(0.4, 0, 0.2, 1)
delay-{n}Delay: 0, 75, 100, 150, 200, 300, 500, 700, 1000 (ms)
animate-noneNo animation
animate-spinContinuous rotation
animate-pingPing/pulse effect
animate-pulseGentle pulsing opacity
animate-bounceBouncing animation

Misc Utilities

ClassValue / Description
overflow-auto / hidden / visible / scrolloverflow property
overflow-x-auto / overflow-y-autoOverflow on one axis
overscroll-auto / contain / noneoverscroll-behavior
opacity-{n}Opacity: 0, 5, 10, 15, 20, 25, ..., 95, 100
scale-{n}Transform scale: 0, 50, 75, 90, 95, 100, 105, 110, 125, 150
rotate-{n}Rotation: 0, 1, 2, 3, 6, 12, 45, 90, 180 (deg)
translate-x-{n} / translate-y-{n}Translate on axis (spacing scale)
skew-x-{n} / skew-y-{n}Skew: 0, 1, 2, 3, 6, 12 (deg)
origin-center / top / bottom / left / right / ...transform-origin
cursor-pointer / default / wait / text / move / not-allowed / ...cursor style
select-none / text / all / autouser-select
pointer-events-none / autopointer-events
resize / resize-none / resize-x / resize-yResize behavior
scroll-smoothscroll-behavior: smooth
snap-start / center / end / align-noneScroll snap alignment
snap-x / snap-y / snap-bothScroll snap type axis
snap-mandatory / snap-proximityScroll snap strictness
aspect-auto / square / videoaspect-ratio: auto / 1/1 / 16/9
object-contain / cover / fill / none / scale-downobject-fit
object-center / top / bottom / left / right / ...object-position
float-left / right / none / start / endfloat
clear-left / right / both / noneclear
isolation-auto / isolateisolation
mix-blend-normal / multiply / screen / overlay / ...mix-blend-mode
bg-blend-normal / multiply / screen / overlay / ...background-blend-mode

Arbitrary Values

When the built-in scale does not have what you need, use square-bracket notation to supply any CSS value:

  • w-[200px]
  • mt-[clamp(1rem,5vw,3rem)]
  • grid-cols-[200px_1fr_200px]
  • bg-[url('/hero.jpg')]
  • text-[color:var(--my-color)]

Related Resources