Gap

Tailwind CSS version
v1.2.0+

Utilities for controlling gutters between grid rows and columns.

Class reference

Class
Properties
.gap-0gap: 0;
.gap-1gap: 0.25rem;
.gap-2gap: 0.5rem;
.gap-3gap: 0.75rem;
.gap-4gap: 1rem;
.gap-5gap: 1.25rem;
.gap-6gap: 1.5rem;
.gap-8gap: 2rem;
.gap-10gap: 2.5rem;
.gap-12gap: 3rem;
.gap-16gap: 4rem;
.gap-20gap: 5rem;
.gap-24gap: 6rem;
.gap-32gap: 8rem;
.gap-40gap: 10rem;
.gap-48gap: 12rem;
.gap-56gap: 14rem;
.gap-64gap: 16rem;
.gap-pxgap: 1px;
.gap-x-0column-gap: 0;
.gap-x-1column-gap: 0.25rem;
.gap-x-2column-gap: 0.5rem;
.gap-x-3column-gap: 0.75rem;
.gap-x-4column-gap: 1rem;
.gap-x-5column-gap: 1.25rem;
.gap-x-6column-gap: 1.5rem;
.gap-x-8column-gap: 2rem;
.gap-x-10column-gap: 2.5rem;
.gap-x-12column-gap: 3rem;
.gap-x-16column-gap: 4rem;
.gap-x-20column-gap: 5rem;
.gap-x-24column-gap: 6rem;
.gap-x-32column-gap: 8rem;
.gap-x-40column-gap: 10rem;
.gap-x-48column-gap: 12rem;
.gap-x-56column-gap: 14rem;
.gap-x-64column-gap: 16rem;
.gap-x-pxcolumn-gap: 1px;
.gap-y-0row-gap: 0;
.gap-y-1row-gap: 0.25rem;
.gap-y-2row-gap: 0.5rem;
.gap-y-3row-gap: 0.75rem;
.gap-y-4row-gap: 1rem;
.gap-y-5row-gap: 1.25rem;
.gap-y-6row-gap: 1.5rem;
.gap-y-8row-gap: 2rem;
.gap-y-10row-gap: 2.5rem;
.gap-y-12row-gap: 3rem;
.gap-y-16row-gap: 4rem;
.gap-y-20row-gap: 5rem;
.gap-y-24row-gap: 6rem;
.gap-y-32row-gap: 8rem;
.gap-y-40row-gap: 10rem;
.gap-y-48row-gap: 12rem;
.gap-y-56row-gap: 14rem;
.gap-y-64row-gap: 16rem;
.gap-y-pxrow-gap: 1px;

Gap

Use .gap-{size} to change the gutter size in grid layouts.

gap-1
gap-2
gap-6
<div class="grid gap-1 grid-cols-2">
  <!-- ... -->
</div>

<div class="grid gap-2 grid-cols-2">
  <!-- ... -->
</div>

<div class="grid gap-6 grid-cols-2">
  <!-- ... -->
</div>

Row Gap

Use .gap-y-{size} to change the gutter size between rows in grid layouts.

gap-y-1
gap-y-2
gap-y-6
<div class="grid gap-y-1 grid-cols-2">
  <!-- ... -->
</div>

<div class="grid gap-y-2 grid-cols-2">
  <!-- ... -->
</div>

<div class="grid gap-y-6 grid-cols-2">
  <!-- ... -->
</div>

Note that prior to Tailwind v1.7.0, these utilities were named .row-gap-{size}. For more information, see the upcoming changes guide.

Column Gap

Use .gap-x-{size} to change the gutter size between columns in grid layouts.

gap-x-1
gap-x-2
gap-x-6
<div class="grid gap-x-1 grid-cols-2">
  <!-- ... -->
</div>

<div class="grid gap-x-2 grid-cols-2">
  <!-- ... -->
</div>

<div class="grid gap-x-6 grid-cols-2">
  <!-- ... -->
</div>

Note that prior to Tailwind v1.7.0, these utilities were named .col-gap-{size}. For more information, see the upcoming changes guide.

Responsive

To control the gap at a specific breakpoint, add a {screen}: prefix to any existing gap utility. For example, use md:gap-6 to apply the gap-6 utility at only medium screen sizes and above.

<div class="grid gap-4 sm:gap-6 md:gap-8 lg:gap-12 xl:gap-16 ...">
  <!-- ... -->
</div>

For more information about Tailwind's responsive design features, check out the Responsive Design documentation.

Customizing

Gap values

By default Tailwind's gap scale matches your configured spacing scale.

You can customize the global spacing scale in the theme.spacing or theme.extend.spacing sections of your tailwind.config.js file:

  // tailwind.config.js
  module.exports = {
    theme: {
      extend: {
        spacing: {
+         '72': '18rem',
+         '84': '21rem',
+         '96': '24rem',
        }
      }
    }
  }

To customize the gap scale separately, use the gap section of your Tailwind theme config.

  // tailwind.config.js
  module.exports = {
    theme: {
      extend: {
        gap: {
+         '11': '2.75rem',
+         '13': '3.25rem',
        }
      }
    }
  }

Learn more about customizing the default theme in the theme customization documentation.

Responsive and pseudo-class variants

By default, only responsive variants are generated for gap utilities.

You can control which variants are generated for the gap utilities by modifying the gap property in the variants section of your tailwind.config.js file.

For example, this config will also generate hover and focus variants:

  // tailwind.config.js
  module.exports = {
    variants: {
      // ...
-     gap: ['responsive'],
+     gap: ['responsive', 'hover', 'focus'],
    }
  }

Disabling

If you don't plan to use the gap utilities in your project, you can disable them entirely by setting the gap property to false in the corePlugins section of your config file:

  // tailwind.config.js
  module.exports = {
    corePlugins: {
      // ...
+     gap: false,
    }
  }

Tailwind UI is now in early access!