Tailwind CSS Grid Generator

Generate Tailwind CSS grid layouts visually. Set columns, rows, gaps, and item placement. Preview live and copy ready-to-use Tailwind grid classes instantly.

How to use Tailwind CSS Grid Generator

  1. 1

    Choose the number of grid columns (1–12).

  2. 2

    Set the gap between grid items.

  3. 3

    Configure span settings for special items (full-width, multi-column).

  4. 4

    Add responsive breakpoints (sm, md, lg) with different column counts.

  5. 5

    Copy the generated Tailwind HTML.

Frequently Asked Questions

What is the most common Tailwind grid pattern?

The responsive card grid: grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6. This gives 1 column on mobile, 2 on tablet, and 3 on desktop.

How do I make an item span multiple columns?

Use col-span-2 through col-span-12, or col-span-full for full-width items.

What is the difference between Tailwind Grid and Flexbox?

Grid is for 2D layouts (rows AND columns simultaneously). Flexbox is better for 1D layouts (either a row OR a column). Cards, dashboards, and galleries use Grid; navbars, buttons, and form rows use Flex.

Detailed Guide

CSS Grid in Tailwind

CSS Grid is the most powerful layout system available in CSS — it lets you define both rows and columns simultaneously, place items precisely, and build complex layouts that Flexbox alone can't handle. Tailwind wraps Grid's power in simple utility classes.


Core Grid Classes

Defining the grid container:

<div class="grid grid-cols-3 gap-4">
  <!-- 3-column grid with 1rem gap -->
</div>

Column presets:

ClassCSS
grid-cols-1Single column
grid-cols-2Two equal columns
grid-cols-3Three equal columns
grid-cols-4 to grid-cols-12Up to 12 equal columns
grid-cols-noneNo column template

Row presets:

ClassCSS
grid-rows-1grid-template-rows: repeat(1, minmax(0, 1fr))
grid-rows-2 to grid-rows-6Up to 6 rows

Gap Control

<div class="grid grid-cols-3 gap-4">    <!-- gap on all sides -->
<div class="grid grid-cols-3 gap-x-4">  <!-- column gap only -->
<div class="grid grid-cols-3 gap-y-6">  <!-- row gap only -->

Spanning Columns and Rows

<!-- Span 2 columns -->
<div class="col-span-2">

<!-- Span full width -->
<div class="col-span-full">

<!-- Span 2 rows -->
<div class="row-span-2">

<!-- Start at column 2 -->
<div class="col-start-2">

Responsive Grid Layouts

The real power of Tailwind grid comes with responsive modifiers:

<!-- 1 col mobile, 2 cols tablet, 4 cols desktop -->
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6">

This is the standard card grid pattern used on almost every modern website.


Common Grid Patterns

Masonry-approximation (unequal heights): Use grid-rows-[masonry] with Subgrid (Tailwind v4) or JavaScript-enhanced CSS.

Holy Grail Layout:

<div class="grid grid-cols-[200px_1fr_200px] grid-rows-[auto_1fr_auto] min-h-screen">
  <header class="col-span-3">...</header>
  <nav>...</nav>
  <main>...</main>
  <aside>...</aside>
  <footer class="col-span-3">...</footer>
</div>

Auto-fill responsive grid:

<div class="grid grid-cols-[repeat(auto-fill,minmax(250px,1fr))] gap-4">

(Use arbitrary values for auto-fill since Tailwind doesn't have a preset for it)


Related Tailwind Tools

Looking for a more detailed deep-dive and advanced tips?

Read Full Article on our Blog