Tailwind CSS Cheat Sheet
A complete reference of Tailwind CSS utility classes for both V3 and V4. Find classes for layout, typography, colors, spacing, responsive design, and more.
Display
Controls the display type of an element
Syntax:
block | inline | inline-block | flex | grid | hidden
Examples:
block
Makes element a block-level elementinline
Makes element an inline elementinline-block
Makes element inline-blockflex
Makes element a flex containergrid
Makes element a grid containerhidden
Hides the elementNotes:
Essential for controlling element layout behavior
Position
Controls how an element is positioned
Syntax:
static | fixed | absolute | relative | sticky
Examples:
static
Default positioningfixed
Fixed relative to viewportabsolute
Absolute positioningrelative
Relative positioningsticky
Sticky positioningNotes:
Use with top, right, bottom, left utilities for precise placement
Top / Right / Bottom / Left
Controls placement of positioned elements
Syntax:
top-{size} | right-{size} | bottom-{size} | left-{size}
Examples:
top-0
top: 0pxright-4
right: 1rembottom-auto
bottom: autoleft-1/2
left: 50%inset-0
top: 0, right: 0, bottom: 0, left: 0Notes:
Works with positioned elements (relative, absolute, fixed, sticky)
Z-Index
Controls stack order of elements
Syntax:
z-{value}
Examples:
z-0
z-index: 0z-10
z-index: 10z-20
z-index: 20z-50
z-index: 50z-auto
z-index: autoNotes:
Higher values appear on top of lower values
Flex Direction
Controls direction of flex items
Syntax:
flex-row | flex-col | flex-row-reverse | flex-col-reverse
Examples:
flex-row
Horizontal direction (default)flex-col
Vertical directionflex-row-reverse
Horizontal reversedflex-col-reverse
Vertical reversedNotes:
Must be used on a flex container
Flex Wrap
Controls whether flex items wrap
Syntax:
flex-wrap | flex-nowrap | flex-wrap-reverse
Examples:
flex-wrap
Allow items to wrapflex-nowrap
Don't allow wrapping (default)flex-wrap-reverse
Wrap in reverse orderNotes:
Determines if items stay on one line or can wrap to new lines
Justify Content
Controls alignment along main axis
Syntax:
justify-start | justify-center | justify-end | justify-between | justify-around | justify-evenly
Examples:
justify-start
Align to start (default)justify-center
Center itemsjustify-end
Align to endjustify-between
Space between itemsjustify-around
Space around itemsjustify-evenly
Even space between itemsNotes:
Controls horizontal alignment in flex-row, vertical in flex-col
Align Items
Controls alignment along cross axis
Syntax:
items-start | items-center | items-end | items-stretch | items-baseline
Examples:
items-start
Align to startitems-center
Center itemsitems-end
Align to enditems-stretch
Stretch to fill (default)items-baseline
Align to baselineNotes:
Controls vertical alignment in flex-row, horizontal in flex-col
Grid Template Columns/Rows
Defines grid track sizing
Syntax:
grid-cols-{n} | grid-rows-{n}
Examples:
grid-cols-1
1 column gridgrid-cols-12
12 column gridgrid-cols-none
No explicit columnsgrid-rows-3
3 row gridgrid-cols-[200px_1fr_100px]
Custom column sizesNotes:
Must be used on a grid container
Column Span
Controls how many columns an element spans
Syntax:
col-span-{n} | col-start-{n} | col-end-{n}
Examples:
col-span-2
Span 2 columnscol-span-full
Span all columnscol-start-2
Start at column 2col-end-4
End at column 4col-auto
Auto column placementNotes:
Used on grid items to control their column placement
Margin
Controls margin (outer spacing) of an element
Syntax:
m-{size} | mx-{size} | my-{size} | mt|mr|mb|ml-{size}
Examples:
m-4
margin: 1rem (all sides)mx-auto
margin-left: auto; margin-right: automy-8
margin-top: 2rem; margin-bottom: 2remmt-2
margin-top: 0.5remml-6
margin-left: 1.5rem-mx-4
Negative horizontal marginNotes:
Spacing scale: 0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 5, 6, 7, 8, 9, 10, 11, 12, etc.
Padding
Controls padding (inner spacing) of an element
Syntax:
p-{size} | px-{size} | py-{size} | pt|pr|pb|pl-{size}
Examples:
p-4
padding: 1rem (all sides)px-6
padding-left: 1.5rem; padding-right: 1.5rempy-2
padding-top: 0.5rem; padding-bottom: 0.5rempt-8
padding-top: 2rempr-0
padding-right: 0Notes:
Uses same spacing scale as margin
Space Between
Controls space between child elements
Syntax:
space-x-{size} | space-y-{size}
Examples:
space-x-4
Add horizontal space between childrenspace-y-2
Add vertical space between childrenspace-x-reverse
Reverse horizontal spacing directionspace-y-reverse
Reverse vertical spacing directionNotes:
Applies margin to all children except the first
Width
Controls the width of an element
Syntax:
w-{size} | w-{fraction} | w-{keyword}
Examples:
w-32
width: 8remw-1/2
width: 50%w-full
width: 100%w-screen
width: 100vww-auto
width: autow-fit
width: fit-contentNotes:
Includes fixed sizes, fractions, and responsive keywords
Height
Controls the height of an element
Syntax:
h-{size} | h-{fraction} | h-{keyword}
Examples:
h-64
height: 16remh-1/3
height: 33.333333%h-full
height: 100%h-screen
height: 100vhh-auto
height: autoh-fit
height: fit-contentNotes:
Similar sizing options as width
Min/Max Width
Controls minimum and maximum width constraints
Syntax:
min-w-{size} | max-w-{size}
Examples:
min-w-0
min-width: 0pxmin-w-full
min-width: 100%max-w-sm
max-width: 24remmax-w-prose
max-width: 65chmax-w-none
max-width: noneNotes:
Useful for responsive design and content constraints
Font Family
Controls the font family of text
Syntax:
font-{family}
Examples:
font-sans
System sans-serif font stackfont-serif
System serif font stackfont-mono
System monospace font stackNotes:
Can be customized in tailwind.config.js
Font Size
Controls the size of text
Syntax:
text-{size}
Examples:
text-xs
font-size: 0.75rem; line-height: 1remtext-sm
font-size: 0.875rem; line-height: 1.25remtext-base
font-size: 1rem; line-height: 1.5remtext-lg
font-size: 1.125rem; line-height: 1.75remtext-xl
font-size: 1.25rem; line-height: 1.75remtext-6xl
font-size: 3.75rem; line-height: 1Notes:
Also sets appropriate line-height for each size
Font Weight
Controls the weight (boldness) of text
Syntax:
font-{weight}
Examples:
font-thin
font-weight: 100font-light
font-weight: 300font-normal
font-weight: 400font-medium
font-weight: 500font-semibold
font-weight: 600font-bold
font-weight: 700font-black
font-weight: 900Notes:
Not all weights are available for every font
Text Align
Controls text alignment
Syntax:
text-{alignment}
Examples:
text-left
text-align: lefttext-center
text-align: centertext-right
text-align: righttext-justify
text-align: justifytext-start
text-align: starttext-end
text-align: endNotes:
text-start and text-end respect text direction (RTL/LTR)
Line Height
Controls the line height of text
Syntax:
leading-{size}
Examples:
leading-3
line-height: 0.75remleading-normal
line-height: 1.5leading-relaxed
line-height: 1.625leading-loose
line-height: 2leading-none
line-height: 1Notes:
Can use numeric values or named sizes
Text Color
Controls the color of text
Syntax:
text-{color}-{shade}
Examples:
text-black
color: #000000text-white
color: #fffffftext-gray-500
color: #6b7280text-red-600
color: #dc2626text-blue-500
color: #3b82f6text-green-400
color: #4ade80Notes:
Color shades range from 50 (lightest) to 950 (darkest)
Background Color
Controls the background color of an element
Syntax:
bg-{color}-{shade}
Examples:
bg-transparent
background-color: transparentbg-white
background-color: #ffffffbg-gray-100
background-color: #f3f4f6bg-blue-500
background-color: #3b82f6bg-red-50
background-color: #fef2f2Notes:
Same color palette as text colors
Border Color
Controls the color of borders
Syntax:
border-{color}-{shade}
Examples:
border-transparent
border-color: transparentborder-gray-300
border-color: #d1d5dbborder-blue-500
border-color: #3b82f6border-red-400
border-color: #f87171Notes:
Must be used with border width utility
Background Size
Controls the size of background images
Syntax:
bg-{size}
Examples:
bg-auto
background-size: autobg-cover
background-size: coverbg-contain
background-size: containNotes:
bg-cover is most commonly used for full coverage
Background Position
Controls the position of background images
Syntax:
bg-{position}
Examples:
bg-center
background-position: centerbg-top
background-position: topbg-bottom
background-position: bottombg-left
background-position: leftbg-right
background-position: rightbg-left-top
background-position: left topNotes:
Can combine positions like bg-left-top
Background Repeat
Controls repetition of background images
Syntax:
bg-{repeat}
Examples:
bg-repeat
background-repeat: repeatbg-no-repeat
background-repeat: no-repeatbg-repeat-x
background-repeat: repeat-xbg-repeat-y
background-repeat: repeat-yNotes:
bg-no-repeat is commonly used with bg-cover
Border Width
Controls border width
Syntax:
border-{width} | border-{side}-{width}
Examples:
border
border-width: 1px (all sides)border-2
border-width: 2px (all sides)border-t
border-top-width: 1pxborder-r-4
border-right-width: 4pxborder-0
border-width: 0pxNotes:
Default border width is 1px when using 'border'
Border Style
Controls border style
Syntax:
border-{style}
Examples:
border-solid
border-style: solidborder-dashed
border-style: dashedborder-dotted
border-style: dottedborder-double
border-style: doubleborder-none
border-style: noneNotes:
border-solid is the default style
Border Radius
Controls border radius (rounded corners)
Syntax:
rounded-{size} | rounded-{corner}-{size}
Examples:
rounded
border-radius: 0.25remrounded-md
border-radius: 0.375remrounded-lg
border-radius: 0.5remrounded-full
border-radius: 9999pxrounded-t-lg
border-top-left-radius: 0.5rem; border-top-right-radius: 0.5remrounded-none
border-radius: 0pxNotes:
rounded-full creates perfect circles for square elements
Box Shadow
Controls box shadow of an element
Syntax:
shadow-{size}
Examples:
shadow-sm
Small shadowshadow
Default shadowshadow-md
Medium shadowshadow-lg
Large shadowshadow-xl
Extra large shadowshadow-none
No shadowshadow-inner
Inner shadowNotes:
Shadows add depth and elevation to elements
Opacity
Controls opacity of an element
Syntax:
opacity-{value}
Examples:
opacity-0
opacity: 0 (invisible)opacity-25
opacity: 0.25opacity-50
opacity: 0.5opacity-75
opacity: 0.75opacity-100
opacity: 1 (fully visible)Notes:
Opacity affects the entire element including children
Scale
Controls scaling transformation
Syntax:
scale-{value} | scale-x-{value} | scale-y-{value}
Examples:
scale-50
transform: scale(0.5)scale-100
transform: scale(1) (default)scale-125
transform: scale(1.25)scale-x-150
transform: scaleX(1.5)scale-y-75
transform: scaleY(0.75)Notes:
Values are percentages: 100 = 100% = normal size
Rotate
Controls rotation transformation
Syntax:
rotate-{degrees}
Examples:
rotate-0
transform: rotate(0deg)rotate-45
transform: rotate(45deg)rotate-90
transform: rotate(90deg)rotate-180
transform: rotate(180deg)-rotate-12
transform: rotate(-12deg)Notes:
Use negative values with dash prefix for counter-clockwise rotation
Translate
Controls translation (movement) transformation
Syntax:
translate-x-{value} | translate-y-{value}
Examples:
translate-x-4
transform: translateX(1rem)translate-y-8
transform: translateY(2rem)-translate-x-2
transform: translateX(-0.5rem)translate-x-1/2
transform: translateX(50%)Notes:
Useful for positioning and animations
Transition Property
Controls which CSS properties transition
Syntax:
transition-{property}
Examples:
transition
Transition common propertiestransition-all
Transition all propertiestransition-colors
Transition color propertiestransition-opacity
Transition opacitytransition-transform
Transition transformstransition-none
No transitionsNotes:
Use with duration and timing utilities for smooth animations
Transition Duration
Controls transition duration
Syntax:
duration-{time}
Examples:
duration-75
transition-duration: 75msduration-150
transition-duration: 150msduration-300
transition-duration: 300msduration-500
transition-duration: 500msduration-1000
transition-duration: 1000msNotes:
300ms is a good default for most transitions
Transition Timing
Controls transition timing function
Syntax:
ease-{function}
Examples:
ease-linear
transition-timing-function: linearease-in
transition-timing-function: ease-inease-out
transition-timing-function: ease-outease-in-out
transition-timing-function: ease-in-outNotes:
ease-in-out provides the most natural feeling transitions
Responsive Breakpoints
Apply utilities at specific screen sizes
Syntax:
sm: | md: | lg: | xl: | 2xl:
Examples:
sm:text-lg
Large text on small screens and upmd:flex
Flex display on medium screens and uplg:w-1/2
Half width on large screens and upxl:px-8
Extra padding on extra large screens2xl:max-w-6xl
Max width on 2xl screens and upNotes:
Breakpoints: sm(640px), md(768px), lg(1024px), xl(1280px), 2xl(1536px)
CSS Variables
Direct CSS variable support in V4
Syntax:
var(--{name})
Examples:
text-[var(--primary)]
Use CSS variable for text colorbg-[var(--surface)]
Use CSS variable for backgroundborder-[var(--accent)]
Use CSS variable for border colorNotes:
V4 has enhanced CSS variable integration
Enhanced Arbitrary Values
Improved arbitrary value support in V4
Syntax:
[value]
Examples:
text-[#1da1f2]
Custom hex colortext-[length:theme(fontSize.lg)]
Theme value referencebg-[color:color-mix(in_srgb,theme(colors.blue.500)_50%,transparent)]
CSS color-mix functionNotes:
V4 provides more powerful arbitrary value syntax
Container Queries
Native container query support in V4
Syntax:
@{size}:
Examples:
@sm:text-lg
Apply when container is small or larger@md:grid-cols-2
2 columns when container is medium@lg:p-8
More padding in large containersNotes:
Container queries allow responsive design based on container size, not viewport
Modern CSS Features
V4 includes modern CSS features out of the box
Syntax:
Various new utilities
Examples:
bg-gradient-to-r
CSS gradients with better syntaxbackdrop-blur-sm
Backdrop filter supportsupports-grid:grid
CSS @supports queriesmotion-reduce:animate-none
Respect user motion preferencesNotes:
V4 embraces modern CSS features and better browser support
Hover States
Apply styles on hover
Syntax:
hover:{utility}
Examples:
hover:bg-blue-500
Blue background on hoverhover:text-white
White text on hoverhover:scale-105
Slightly scale up on hoverhover:shadow-lg
Larger shadow on hoverNotes:
Essential for interactive elements like buttons and links
Focus States
Apply styles when element is focused
Syntax:
focus:{utility}
Examples:
focus:outline-none
Remove default focus outlinefocus:ring-2
Add focus ringfocus:ring-blue-500
Blue focus ring colorfocus:border-blue-500
Blue border on focusNotes:
Important for accessibility and keyboard navigation
Active States
Apply styles when element is being pressed/clicked
Syntax:
active:{utility}
Examples:
active:bg-blue-700
Darker background when pressedactive:scale-95
Slightly scale down when pressedactive:transform
Enable transforms for active stateNotes:
Provides immediate feedback when users interact with elements
Pro Tailwind Tips
Related Resources
Essential Patterns
flex items-center justify-center
- Perfect centeringgrid grid-cols-1 md:grid-cols-2
- Responsive gridmax-w-4xl mx-auto
- Centered containerspace-y-4
- Consistent vertical spacingtransition-all duration-300
- Smooth animationsfocus:ring-2 focus:ring-blue-500
- Accessible focus
Best Practices
- Use semantic color names (primary, secondary) in config
- Leverage responsive prefixes:
sm:
,md:
,lg:
- Group related utilities together for readability
- Use arbitrary values sparingly:
[14px]
- Create component classes for repeated patterns
- Test dark mode with
dark:
variants
V3 vs V4 Key Differences
- • V4: Enhanced CSS variable support
- • V4: Native container queries (@sm:, @md:)
- • V4: Better arbitrary value syntax
- • V4: Modern CSS features built-in
- • V4: Smaller bundle sizes
Common Component Pattern
/* Button Component */ class="px-4 py-2 bg-blue-500 text-white font-medium rounded-lg shadow-sm hover:bg-blue-600 focus:ring-2 focus:ring-blue-500 transition-colors duration-200"
Version Compatibility
Feature | Tailwind V3 | Tailwind V4 |
---|---|---|
Core Utilities | ||
Container Queries | ||
Enhanced CSS Variables | ||
Modern CSS Features |