Tariq Brown

Tariq Brown

Software Engineer

A Beginner's Guide to Responsive Design with TailwindCSS

avatar
Tariq

·

Aug 19, 2025

·

2 min read

Cover image

One of the best things that I love about TailwindCSS is how incredibly easy it is to build responsive designs. Too many times have I seen sites that seemed to look perfectly fine at first, and then realise that the layout completely falls apart when viewing that same site on a smaller device.

With Tailwind, instead of writing long custom media queries with traditional CSS, I could apply responsive classes directly in my HTML. This post will walk you through the fundamentals of responsive design with Tailwind, along with some practical examples that I use myself.

Tailwind’s Mobile First Approach

Tailwind uses a mobile-first design strategy that is commonly applied to various websites, and is a key principle in responsive web design. This means that styles apply to smaller screens by default, and I add responsive variants as the screen size increases. For example:

<p class="text-sm md:text-base lg:text-lg">
    This text scales with screen size
</p>
  • On mobile (default): text-sm

  • On medium screens (md: breakpoint): text-base

  • On large screens (lg: breakpoint): text-lg

This way, I can progressively enhance my design as the screen grows.

Default breakpoints

Here are the default breakpoints that I personally work with:

  • sm → 640px

  • md → 768px

  • lg → 1024px

  • xl → 1280px

  • 2xl → 1536px

Dark Mode Responsiveness

Responsive design isn’t just about the viewport; it’s also about user context. With Tailwind’s dark mode support, I can make designs that adapt not only to device size, but also to user preferences.

By default, Tailwind lets me toggle dark mode using the dark: variant. I often combine it with breakpoints to create adaptive themes:

<div class="bg-white text-black dark:bg-gray-900 dark:text-white md:dark:bg-gray-800">
  <p>Adaptive with both theme and screen size!</p>
</div>

On mobile in light mode, this uses a white background. On larger screens in dark mode, it switches to a slightly lighter gray background for contrast. This way, I can fine-tune the dark theem based on screen size.

Tips for Better Responsive Design

  • Start small: I design for mobile first, then scale up.

  • Test often: I resize my browser or use dev tools to check different devices.

  • Use utility classes smartly: I avoid overloading elements with too many classes and extract components if needed.

  • Think content-first: I let my content guide how the layout should adapt.

Wrapping up

If you wan to explore further, the TailwindCSS Responsive Design Docs are a great starting point, but don’t be afraid to experiment and extend Tailwind to suit your needs.