All Posts

How to use breakpoints in Tailwind CSS

Responsive design is all about making your site look good everywhere. Phone, tablet, desktop – it needs to work.

The old way meant writing tons of media queries, jumping between CSS files, and hoping you didn't miss a breakpoint somewhere. Honestly, it was a pain.

Tailwind changed this completely. You just prefix a class with the screen size you want, and you're done. No more separate CSS files or hunting down media queries. Everything happens right in your HTML.

Let me show you how it works.

Mobile-first responsive design

Here's the thing about Tailwind breakpoints – they work mobile-first. That means when you add a class without a prefix, it applies to ALL screen sizes. When you add a prefix like md: or lg:, it kicks in at that size and stays active for everything larger.

This trips people up at first. You might think sm:text-center means "center text on small screens." But that's wrong. It actually means "center text starting at the small breakpoint and above."

Let me show you a better way to think about it:

<div class='max-w-2xl mx-auto space-y-6 p-6'>
  <div class='bg-white rounded-lg shadow-md p-6 border-2 border-blue-200'>
    <h3 class='text-lg font-semibold text-gray-800 mb-3'>Mobile-First Example</h3>
    <p class='text-center md:text-left text-gray-700 mb-2'>
      This text is centered on mobile (default)
    </p>
    <p class='text-center md:text-left text-gray-700'>
      But switches to left-aligned on medium screens and up
    </p>
  </div>

  <div class='bg-gray-50 rounded-lg p-4 border border-gray-300'>
    <p class='text-sm text-gray-600 mb-2'><strong>How it works:</strong></p>
    <ul class='text-sm text-gray-600 space-y-1 list-disc list-inside'>
      <li>Mobile (default): <code class='bg-gray-200 px-1 rounded'>text-center</code> applies</li>
      <li>Medium screens (768px+): <code class='bg-gray-200 px-1 rounded'>md:text-left</code> overrides it</li>
      <li>Larger screens: Stays left-aligned</li>
    </ul>
  </div>
</div>

See how that works? You start with the mobile version (no prefix), then add prefixed classes for larger screens. The mobile style is your foundation, and you build up from there.

This also keeps your HTML cleaner. Instead of writing separate styles for every screen size, you only write what changes.

The five default breakpoints

Tailwind ships with five breakpoints out of the box. These cover most common device sizes you'll encounter:

Breakpoint

Min Width

Pixels

What it targets

sm

40rem

640px

Phones (landscape) and up

md

48rem

768px

Tablets and up

lg

64rem

1024px

Laptops and up

xl

80rem

1280px

Desktops and up

2xl

96rem

1536px

Large desktops

Notice how they're defined in rem units instead of pixels. This helps with accessibility since rem scales with the user's font size preferences.

Here's how you'd use them to build a responsive grid that adapts at different screen sizes:

<div class='max-w-6xl mx-auto p-6'>
  <div class='mb-6'>
    <h3 class='text-xl font-semibold text-gray-800 mb-2'>Responsive Grid Demo</h3>
    <p class='text-gray-600 text-sm'>Resize your browser to see how the grid changes at different breakpoints</p>
  </div>

  <div class='grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-6 gap-4 mb-6'>
    <div class='bg-blue-500 text-white rounded-lg p-6 flex items-center justify-center font-semibold'>1</div>
    <div class='bg-blue-500 text-white rounded-lg p-6 flex items-center justify-center font-semibold'>2</div>
    <div class='bg-blue-500 text-white rounded-lg p-6 flex items-center justify-center font-semibold'>3</div>
    <div class='bg-blue-500 text-white rounded-lg p-6 flex items-center justify-center font-semibold'>4</div>
    <div class='bg-blue-500 text-white rounded-lg p-6 flex items-center justify-center font-semibold'>5</div>
    <div class='bg-blue-500 text-white rounded-lg p-6 flex items-center justify-center font-semibold'>6</div>
  </div>

  <div class='bg-gray-100 rounded-lg p-4'>
    <p class='text-sm text-gray-700 mb-2'><strong>Current layout:</strong></p>
    <ul class='text-sm text-gray-600 space-y-1'>
      <li class='block sm:hidden'>📱 Mobile: 1 column</li>
      <li class='hidden sm:block md:hidden'>📱 Small (640px+): 2 columns</li>
      <li class='hidden md:block lg:hidden'>📱 Medium (768px+): 3 columns</li>
      <li class='hidden lg:block xl:hidden'>💻 Large (1024px+): 4 columns</li>
      <li class='hidden xl:block'>🖥️ Extra Large (1280px+): 6 columns</li>
    </ul>
  </div>
</div>

The grid starts as a single column on mobile. When you hit 640px (sm), it switches to 2 columns. At 768px (md), it becomes 3 columns. Then 4 at 1024px (lg), and finally 6 columns at 1280px (xl).

You can apply these breakpoint prefixes to ANY Tailwind utility. Text size, spacing, colors, flexbox, grid – everything works with breakpoints.

Targeting breakpoint ranges

Sometimes you need to style something only at a specific screen size – not mobile, not desktop, but tablets only. Tailwind has you covered with max-width variants.

The max variants work backwards from the regular ones. Instead of "this breakpoint and up," they mean "below this breakpoint."

Here's what's available:

  • @max-sm - Below 640px (mobile only)
  • @max-md - Below 768px
  • @max-lg - Below 1024px
  • @max-xl - Below 1280px
  • @max-2xl - Below 1536px

You can combine min and max variants to target specific ranges. Want to show something only on tablets? Use md:max-lg:flex:

<div class='max-w-4xl mx-auto p-6 space-y-6'>
  <div class='bg-white rounded-lg shadow-lg p-6'>
    <h3 class='text-lg font-semibold text-gray-800 mb-4'>Device-Specific Messages</h3>

    <div class='space-y-3'>
      <div class='@max-sm:block hidden bg-blue-500 text-white rounded-lg p-4 text-center font-medium'>
        📱 You're on mobile (below 640px)
      </div>

      <div class='hidden sm:block md:hidden bg-green-500 text-white rounded-lg p-4 text-center font-medium'>
        📱 You're on a small device (640px - 767px)
      </div>

      <div class='hidden md:block lg:hidden bg-purple-500 text-white rounded-lg p-4 text-center font-medium'>
        💻 You're on a tablet (768px - 1023px)
      </div>

      <div class='hidden lg:block xl:hidden bg-orange-500 text-white rounded-lg p-4 text-center font-medium'>
        🖥️ You're on a laptop (1024px - 1279px)
      </div>

      <div class='hidden xl:block bg-red-500 text-white rounded-lg p-4 text-center font-medium'>
        🖥️ You're on a large desktop (1280px+)
      </div>
    </div>
  </div>

  <div class='bg-gray-100 rounded-lg p-4'>
    <p class='text-sm text-gray-700 font-semibold mb-2'>Common use cases:</p>
    <ul class='text-sm text-gray-600 space-y-1 list-disc list-inside'>
      <li>Hide navigation on mobile, show on desktop</li>
      <li>Different image sizes for different devices</li>
      <li>Tablet-specific layouts</li>
      <li>Conditional content based on screen size</li>
    </ul>
  </div>
</div>

This is super handy when you need different layouts for different device types. Maybe your desktop has a sidebar, tablets get a simplified version, and mobile is completely different.

Just be careful not to go overboard. Usually the mobile-first approach handles most cases without needing specific ranges.

Creating custom breakpoints

The default breakpoints work great for most projects. But sometimes you need something different – maybe an extra small breakpoint for tiny phones, or a 3xl for ultra-wide monitors.

Tailwind v4 makes this simple with theme variables. You just add them to your CSS file using the @theme directive:

<div class='max-w-4xl mx-auto p-6'>
  <div class='bg-white rounded-lg shadow-lg p-6 mb-6'>
    <h3 class='text-lg font-semibold text-gray-800 mb-4'>Custom Breakpoint Demo</h3>
    <p class='text-sm text-gray-600 mb-4'>This example uses custom xs (480px) and 3xl (1920px) breakpoints</p>

    <div class='bg-gradient-to-r from-blue-500 to-purple-500 text-white rounded-lg p-6 text-center'>
      <p class='text-base xs:text-lg sm:text-xl md:text-2xl lg:text-3xl xl:text-4xl'>
        Watch this text grow
      </p>
      <p class='text-sm mt-2 opacity-90'>
        It responds to both default and custom breakpoints
      </p>
    </div>
  </div>

  <div class='grid grid-cols-1 gap-4'>
    <div class='bg-gray-100 rounded-lg p-4'>
      <p class='text-sm font-semibold text-gray-700 mb-2'>Breakpoints in use:</p>
      <ul class='text-sm text-gray-600 space-y-1 list-disc list-inside'>
        <li><code class='bg-white px-1 rounded'>xs:</code> 480px (custom)</li>
        <li><code class='bg-white px-1 rounded'>sm:</code> 640px (default)</li>
        <li><code class='bg-white px-1 rounded'>md:</code> 768px (default)</li>
        <li><code class='bg-white px-1 rounded'>lg:</code> 1024px (default)</li>
        <li><code class='bg-white px-1 rounded'>xl:</code> 1280px (default)</li>
        <li><code class='bg-white px-1 rounded'>3xl:</code> 1920px (custom)</li>
      </ul>
    </div>
  </div>
</div>

Now you can use xs: and 3xl: prefixes just like the default ones. Pretty straightforward.

You can also modify existing breakpoints. Want to change md from 768px to 800px? Just override it:

@theme {
  --breakpoint-md: 50rem; /* 800px */
}

Or if you want to completely replace all the defaults with your own system, reset them first:

@theme {
  --breakpoint-*: initial;
  --breakpoint-mobile: 30rem;
  --breakpoint-tablet: 48rem;
  --breakpoint-desktop: 80rem;
}

One thing to keep in mind: always use the same unit for all your breakpoints. Mixing rem and px can mess up the ordering, and your breakpoints won't work as expected.

Using arbitrary breakpoint values

Sometimes you need a one-off breakpoint for a specific element. Maybe your design breaks at 900px, but you don't want to add that to your whole theme configuration.

Tailwind lets you use arbitrary values with the min and max modifiers:

<div class='max-w-4xl mx-auto p-6'>
  <div class='bg-white rounded-lg shadow-lg p-6 mb-6'>
    <h3 class='text-lg font-semibold text-gray-800 mb-4'>One-Off Breakpoint Example</h3>
    <p class='text-sm text-gray-600 mb-4'>These styles use custom breakpoint values that aren't in the theme</p>

    <div class='space-y-4'>
      <div class='bg-blue-500 text-white rounded-lg p-4 min-[500px]:bg-green-500 min-[800px]:bg-purple-500 min-[1100px]:bg-orange-500 text-center font-medium transition-colors'>
        Watch me change colors at custom breakpoints
      </div>

      <div class='grid grid-cols-1 min-[600px]:grid-cols-2 min-[900px]:grid-cols-3 min-[1200px]:grid-cols-4 gap-4'>
        <div class='bg-gray-200 rounded-lg p-4 flex items-center justify-center'>Box 1</div>
        <div class='bg-gray-200 rounded-lg p-4 flex items-center justify-center'>Box 2</div>
        <div class='bg-gray-200 rounded-lg p-4 flex items-center justify-center'>Box 3</div>
        <div class='bg-gray-200 rounded-lg p-4 flex items-center justify-center'>Box 4</div>
      </div>
    </div>
  </div>

  <div class='bg-gray-100 rounded-lg p-4'>
    <p class='text-sm font-semibold text-gray-700 mb-2'>Color changes:</p>
    <ul class='text-sm text-gray-600 space-y-1 list-disc list-inside'>
      <li>Blue: Below 500px</li>
      <li>Green: 500px - 799px</li>
      <li>Purple: 800px - 1099px</li>
      <li>Orange: 1100px and up</li>
    </ul>
    <p class='text-sm font-semibold text-gray-700 mt-4 mb-2'>Grid changes:</p>
    <ul class='text-sm text-gray-600 space-y-1 list-disc list-inside'>
      <li>1 column: Below 600px</li>
      <li>2 columns: 600px - 899px</li>
      <li>3 columns: 900px - 1199px</li>
      <li>4 columns: 1200px and up</li>
    </ul>
  </div>
</div>

This is perfect for edge cases. Your designer wants something specific at 850px? No problem. Just use min-[850px]:whatever and move on.

But don't go crazy with this. If you find yourself using the same arbitrary value multiple times, that's a sign you should add it to your theme configuration instead.

Also remember to stick with one unit. Don't mix min-[900px] and min-[50rem] in the same project – it'll cause headaches when breakpoints don't fire in the order you expect.

That's everything you need to know about breakpoints in Tailwind CSS. Start with the defaults, use the mobile-first approach, and add custom breakpoints when needed.

The beauty of Tailwind's system is that it keeps you in your HTML. No jumping between files, no hunting for the right media query. Just prefix a class and you're done.

Now go build something responsive!

Other posts you might like...

See more

Subscribe to our newsletter

Get notified when we add new templates, components, and more!

Thanks for subscribing!
Please check your email to confirm your subscription.

WindyBase Make development a breeze

WindyBase is a weekly curated Tailwind CSS template and tool directory built for the modern developer.

© 2026 WindyBase. All rights reserved.