Skip to content

Grid

CSS Grid Layout is a powerful system for creating complex, two-dimensional layouts. To begin, add the is-grid class to a container element.

Grid Template Columns

Use these utilities to define the number of columns in your grid. The columns will have equal width and take up all available space.

ClassCSS
is-grid-cols-1grid-template-columns: repeat(1, minmax(0, 1fr));
is-grid-cols-2grid-template-columns: repeat(2, minmax(0, 1fr));
is-grid-cols-3grid-template-columns: repeat(3, minmax(0, 1fr));
is-grid-cols-4grid-template-columns: repeat(4, minmax(0, 1fr));
is-grid-cols-5grid-template-columns: repeat(5, minmax(0, 1fr));
is-grid-cols-6grid-template-columns: repeat(6, minmax(0, 1fr));

Use Case: Creating a product listing, photo gallery, or any other content that needs to be arranged in a multi-column layout.

Example: A responsive 3-column grid that becomes a 1-column grid on smaller screens.

html
<div class="is-grid sm:is-grid-cols-3 is-gap-4">
  <div class="is-bg-blue-5 is-p-4 is-rounded-lg">Item 1</div>
  <div class="is-bg-blue-5 is-p-4 is-rounded-lg">Item 2</div>
  <div class="is-bg-blue-5 is-p-4 is-rounded-lg">Item 3</div>
  <div class="is-bg-blue-5 is-p-4 is-rounded-lg">Item 4</div>
  <div class="is-bg-blue-5 is-p-4 is-rounded-lg">Item 5</div>
  <div class="is-bg-blue-5 is-p-4 is-rounded-lg">Item 6</div>
</div>

Grid Template Rows

Use these utilities to define the number of rows in your grid.

ClassCSS
is-grid-rows-1grid-template-rows: repeat(1, minmax(0, 1fr));
is-grid-rows-2grid-template-rows: repeat(2, minmax(0, 1fr));
is-grid-rows-3grid-template-rows: repeat(3, minmax(0, 1fr));
is-grid-rows-4grid-template-rows: repeat(4, minmax(0, 1fr));
is-grid-rows-5grid-template-rows: repeat(5, minmax(0, 1fr));
is-grid-rows-6grid-template-rows: repeat(6, minmax(0, 1fr));

Gap

Control the gap between grid items using the is-gap-* utilities. This is the modern way to add space between elements, replacing the need for margins in many cases.

ClassCSS
is-gap-0gap: 0;
is-gap-1gap: 0.25rem;
is-gap-2gap: 0.5rem;
is-gap-3gap: 0.75rem;
is-gap-4gap: 1rem;
is-gap-5gap: 1.25rem;
is-gap-6gap: 1.5rem;
is-gap-8gap: 2rem;
is-gap-10gap: 2.5rem;
is-gap-12gap: 3rem;

Example: A 2-column grid with a large gap between the items.

html
<div class="is-grid is-grid-cols-2 is-gap-8">
  <div class="is-bg-green-5 is-p-4 is-rounded-lg">Item 1</div>
  <div class="is-bg-green-5 is-p-4 is-rounded-lg">Item 2</div>
  <div class="is-bg-green-5 is-p-4 is-rounded-lg">Item 3</div>
  <div class="is-bg-green-5 is-p-4 is-rounded-lg">Item 4</div>
</div>