Tailwind CSS provides a mobile-first responsive design system using breakpoint prefixes that make it easy to build adaptive layouts.
Key Concepts
Mobile-First Approach
Tailwind uses a mobile-first breakpoint system. Unprefixed utilities apply to all screen sizes, and breakpoint prefixes apply from that breakpoint and up:
Responsive width
Default Breakpoints
// tailwind.config.js default breakpoints
{
sm: '640px', // Small devices (landscape phones)
md: '768px', // Medium devices (tablets)
lg: '1024px', // Large devices (desktops)
xl: '1280px', // Extra large devices (large desktops)
'2xl': '1536px' // 2X large devices (larger desktops)
}
Best Practices
1. Start Mobile, Scale Up
Design for mobile first, then add complexity for larger screens:
Column 1
Column 2
2. Use Responsive Typography
Scale text appropriately across devices:
Responsive Heading
Body text that scales
3. Responsive Spacing
Adjust padding and margins for different screens:
4. Grid Layouts
Create responsive grids that adapt to screen size:
Item 1
Item 2
Item 3
Item 4
5. Show/Hide Elements
Control visibility across breakpoints:
Mobile only
Desktop only
Examples
Responsive Hero Section
Welcome to Our Site
This is a responsive hero section that adapts to all screen sizes.