Every Tailwind class can be made responsive with a breakpoint prefix.
| Prefix | Min width |
|---|---|
sm: |
640px |
md: |
768px |
lg: |
1024px |
xl: |
1280px |
2xl: |
1536px |
Mobile-first
Classes without a prefix apply to all screens. Prefixed classes apply from that size and up.
<div class="text-center md:text-left">
Centred on phones, left-aligned from tablets up.
Common patterns
- Stack on mobile, row on desktop:
flex flex-col md:flex-row - Grid columns:
grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 - Hide on mobile:
hidden md:block - Show only on mobile:
md:hidden
Max-width variants
max-md: applies below a breakpoint, e.g. max-md:p-2.
Example
Example — Responsive layout
HTML
<script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>
<div class="p-4">
<h1 class="text-2xl md:text-4xl font-bold text-center md:text-left">Resize the preview</h1>
<p class="md:hidden mt-2 text-rose-600">You are on a small screen.</p>
<p class="hidden md:block mt-2 text-emerald-600">You are on a medium or larger screen.</p>
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4 mt-6">
<div class="bg-sky-500 text-white p-6 rounded-lg">1</div>
<div class="bg-sky-500 text-white p-6 rounded-lg">2</div>
<div class="bg-sky-500 text-white p-6 rounded-lg">3</div>
<div class="bg-sky-500 text-white p-6 rounded-lg">4</div>
</div>
</div>