All articles

The secret to responsive design isn't magic, it's these Tailwind tricks that saved me from embarrassment.

Frontend · 18 Aug 2025 · Michael Quintero

Introduction

We’ve all been there: you create a perfect design on your laptop and, when you see it on a phone, it’s a disaster. Elements get crammed together, images spill off the screen, and the user experience collapses.

Creating a responsive design isn’t optional, it’s the standard. The good news is that with Tailwind, the mobile-first mindset is already built in. Today I’ll give you the tricks that have saved my life so your work looks amazing on any screen—without breaking a sweat.

The ABC of breakpoint prefixes

The foundation of Tailwind is its breakpoint prefix system. By default, all classes apply to the smallest screen size, and you can override behavior on larger screens:

  • sm: 640px
  • md: 768px
  • lg: 1024px
  • xl: 1280px
  • 2xl: 1536px

Example 1: A card that changes layout

<div class="flex flex-col md:flex-row">
  <div class="md:w-1/2">
    <img src="..." class="w-full">
  </div>
  <div class="md:w-1/2 p-4">
    <h2 class="text-xl md:text-2xl font-bold">Card title</h2>
    <p class="mt-2 text-gray-600">Product description...</p>
  </div>
</div>

By default, the layout will be in a column, but starting at md: it becomes a row with two equal columns.

Trick 1: The magic grid with Flexbox and Grid

For creating adaptable layouts, nothing beats flexbox and grid.

Example 2: A responsive product gallery

<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
  <div>...</div>
  <div>...</div>
  <div>...</div>
</div>

On mobile the gallery has 1 column, on medium screens 2, and on large screens 3.

Trick 2: Visibility classes (hidden and block)

Sometimes you want an element to appear only at certain screen sizes, like in a navigation menu.

Example 3: A hamburger menu on mobile

<nav>
  <ul class="hidden md:flex space-x-4">
    <li><a href="#">Home</a></li>
    <li><a href="#">About</a></li>
    <li><a href="#">Contact</a></li>
  </ul>

  <button class="md:hidden">
  </button>
</nav>

With hidden and md:flex you control which elements are visible on each device.

Conclusion

Mastering responsive design is a fundamental skill. With Tailwind’s mobile-first mindset and these tricks, your work will look amazing on any device. That makes you a developer who thinks about all their users.

I write these articles while designing and building interfaces for clients. If you want something like this in your project, see my frontend design and development services or how I rebuilt the Clínica de Urgencias Bucaramanga website.