Back to HomeEssential Tailwind CSS utilities, patterns, and best practices for rapid UI development.
colors & themes
Use semantic color scales and CSS variables for maximum flexibility.
- 1
bg-gray-50 to bg-gray-950 for full grayscale spectrum
- 2
text-blue-600 for standard blue text
- 3
border-red-500 for error state borders
- 4
Use bg-foreground and text-foreground for semantic colors
- 5
Combine with opacity:bg-black/20
spacing & sizing
Consistent spacing creates visual harmony. Based on 0.25rem (4px) increments.
- 1
p-4 = 1rem (16px) padding
- 2
m-6 = 1.5rem (24px) margin
- 3
gap-2 = 0.5rem (8px) gap in flex/grid
- 4
space-y-4 = 1rem vertical spacing between children
- 5
w-full = 100% width, h-screen = 100vh height
- 6
max-w-5xl = Maximum width container
responsive design
Mobile-first approach. Start with mobile styles, then add breakpoints.
- 1
Breakpoints:
sm: 640px, md: 768px, lg: 1024px, xl: 1280px, 2xl: 1536px
- 2
Responsive grid:<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3">
- 3
Responsive text:<h1 class="text-4xl md:text-5xl">
- 4
Show/hide:<div class="hidden md:block">
- 5
Responsive padding:<div class="px-4 md:px-6 lg:px-8">
layout & flexbox
Flexbox and Grid make layouts effortless.
- 1
Center content:<div class="flex items-center justify-center">
- 2
Space between:<div class="flex justify-between items-center">
- 3
Vertical stack:<div class="flex flex-col gap-4">
- 4
Grid layout:<div class="grid grid-cols-3 gap-6">
- 5
Position types: relative, absolute, fixed, sticky
typography
Font sizes, weights, and line heights for readability.
- 1
text-xs = 0.75rem (12px)
- 2
text-sm = 0.875rem (14px)
- 3
text-base = 1rem (16px)
- 4
text-lg = 1.125rem (18px)
- 5
text-4xl = 2.25rem (36px)
- 6
Font weights: font-normal (400), font-medium (500), font-semibold (600), font-bold (700)
- 7
Truncate text:<p class="truncate">
- 8
Multi-line clamp:<p class="line-clamp-2">
effects & transitions
Transitions, shadows, and hover states make interfaces feel alive.
- 1
Smooth transitions:<button class="transition-colors hover:bg-gray-100">
- 2
Custom duration:<div class="transition-all duration-300">
- 3
Transform on hover:<div class="hover:-translate-y-1 transition-transform">
- 4
Shadows: shadow-sm, shadow-md, shadow-lg, shadow-xl
- 5
Focus rings:<input class="focus:ring-2 focus:ring-blue-500">
- 6
Group hover:<div class="group"><h3 class="group-hover:text-blue-500"></div>
- 7
Rounded corners: rounded, rounded-lg, rounded-2xl, rounded-full