Monday, March 16, 2026

4 Causes That Make Tailwind Nice for Constructing Layouts


Once I discuss layouts, I’m referring to the way you place objects on a web page. The CSS properties which are broadly used right here embrace:

  • show — usually grid or flex these days
  • margin
  • padding
  • width
  • peak
  • place
  • high, left, backside, proper

I usually embrace border-width as a minor merchandise on this listing as effectively.

At this level, there’s just one factor I’d prefer to say.

Tailwind is actually nice for making layouts.

There are numerous the reason why.

First: Format types are extremely depending on the HTML construction

After we shift layouts into CSS, we lose the psychological construction and it takes effort to re-establish them. Think about the next three-column grid in HTML and CSS:

.grid {
  show: grid;
  grid-template-columns: 2fr 1fr;

  .grid-item:first-child {
    grid-column: span 2
  }

  .grid-item:last-child {
    grid-column: span 1
  }
}

Now cowl the HTML construction and simply learn the CSS. As you try this, discover it is advisable to exert effort to think about the HTML construction that this is applicable to.

Now think about the identical, however constructed with Tailwind utilities:

You may virtually start to see the structure manifest in your eyes with out seeing the precise output. It’s fairly clear: A 3-column grid, first merchandise spans two columns whereas the second spans one column.

However grid-cols-3 and col-span-2 are kinda bizarre and foreign-looking as a result of we’re making an attempt to parse Tailwind’s methodology of writing CSS.

Now, watch what occurs after we shift the syntax out of the best way and use CSS variables to outline the structure as a substitute. The structure turns into crystal clear instantly:

Two blue rectangles side-by-side illustrating a two-column layout where the left column is twice the width of the right column.

Similar three-column structure.

Nevertheless it makes the structure a lot simpler to put in writing, learn, and visualize. It additionally has different advantages, however I’ll allow you to discover its documentation as a substitute of explaining it right here.

For now, let’s transfer on.

Why not use 2fr 1fr?

It is sensible to put in writing 2fr 1fr for a three-column grid, doesn’t it?

.grid {
  show: grid;
  grid-template-columns: 2fr 1fr;
}

Sadly, it received’t work. It's because fr is calculated based mostly on the accessible area after subtracting away the grid’s gutters (or hole).

Since 2fr 1fr solely comprises two columns, the output from 2fr 1fr can be completely different from a normal three-column grid.

Three examples of multi-column layouts stacked. The first is an equal three-column layout, the second and third are two columns where the left column is double the width of the right column.

Alright. Let’s proceed with the explanations that make Tailwind nice for constructing layouts.

Second: No want to call layouts

I believe layouts are the toughest issues to call. I hardly ever provide you with higher names than:

  • Quantity + Columns, e.g. .two-columns
  • Semantic names, e.g. .content-sidebar

However these names don’t do the structure justice. You may’t actually inform what’s occurring, even in the event you see .two-columns, as a result of .two-columns can imply a wide range of issues:

  • Two equal columns
  • Two columns with 1fr auto
  • Two columns with auto 1fr
  • Two columns that spans complete of seven “columns” and the primary object takes up 4 columns whereas the second takes up 3…

You may already see me tripping up when I attempt to clarify that final one there…

As a substitute of forcing ourselves to call the structure, we will let the numbers do the speaking — then the entire construction turns into very clear.

The variables paint an image.

Example of a seven-column layout above a two-column layout with equally-sized columns.

Third: Format necessities can change relying on context

A “two-column” structure may need completely different properties when utilized in completely different contexts. Right here’s an instance.

Two two-by-two layouts next to each other. In both cases, the third item wraps to the second line, followed by the fourth item.

On this instance, you'll be able to see that:

  • A bigger hole is used between the I and J teams.
  • A smaller hole is used inside the I and J teams.

The distinction in hole sizes is delicate, however used to indicate that the objects are of separate teams.

Right here’s an instance the place this idea is utilized in an actual challenge. You may see the distinction between the hole used inside the publication container and the hole used between the publication and quote containers.

A two-column layout for a newsletter signup component with the form as the left column that is wider than the width of the right column, containing content.

If this type of structure is barely utilized in one place, we don’t must create a modifier class simply to alter the hole worth. We will change it straight.

One other frequent instance

Let’s say you may have a heading for a advertising and marketing part. The heading would look nicer if you'll be able to range its max-width so the textual content isn’t orphaned.

text-balance may work right here, however that is usually nicer with handbook positioning.

With out Tailwind, you may write an inline type for it.

Your subscription has been confirmed

With Tailwind, you'll be able to specify the max-width in a extra terse approach:

Your subscription has been confirmed

A centered heading in black that says Your subscription has been confirmed.

Fourth: Responsive variants may be created on the fly

“At which breakpoint would you alter your layouts?” is one other issue you’d wish to contemplate when designing your layouts. I shall time period this the responsive issue for this part.

More than likely, comparable layouts ought to have the identical responsive issue. In that case, it is sensible to group the layouts collectively right into a named structure.

.two-column {
  @apply grid-simple;
  /* --cols: 1 is the default */

  @media (width >= 800px) {
    --cols:2;
  }
}

Nevertheless, you will have layouts the place you need two-column grids on a cellular and a a lot bigger column rely on tablets and desktops. This structure type is usually utilized in a website footer part.

For the reason that footer grid is exclusive, we will add Tailwind’s responsive variants and alter the structure on the fly.

Example of a footer that adapts to the screen size. It goes from a two-column layout on small screens to a five-column layout on wider screens.

Once more, we get to create a brand new structure on the fly with out creating a further modifier class — this retains our CSS clear and targeted.

Methods to greatest use Tailwind

This text is a pattern lesson from my course, Unorthodox Tailwind, the place I present you use Tailwind and CSS synergistically.

Personally, I believe one of the best ways to make use of Tailwind is to not litter your HTML with Tailwind utilities, however to create utilities that allow you to create layouts and types simply.

I cowl far more of that within the course in the event you’re to seek out out extra!

Related Articles

Latest Articles