Grid
Use a mobile-first twelve column CSS grid to build responsive layouts.
Syntax
Add .grid to the parent and column utilities to its direct children. The default grid has twelve equal tracks; .col-{n} spans n tracks, and .col-{breakpoint}-{n} changes that span from a breakpoint upward. Add a gap utility to adjust the space between items.
<div class="grid gap-3">
<div class="col-12 col-md-8">Main content</div>
<div class="col-12 col-md-4">Sidebar</div>
</div>Class and token reference
Available column classes
The Sass grid rules generate these utility families. Numbers refer to tracks or grid lines rather than percentages.
| Class or pattern | Effect |
|---|---|
.grid |
Creates twelve equal columns. |
.col, .col-12 |
Spans the full twelve-column row. |
.col-{n} |
Spans 1 to 12 columns. |
.col-start-{n}, .col-end-{n} |
Places an edge on grid line 1 to 13. |
.col-offset-{n} |
Leaves 1 to 11 columns before the item; 0 restores automatic placement. |
.row-span-{n} |
Spans 1 to 12 rows. |
.grid-auto-fit |
Uses as many flexible columns as the container can fit; combine with .grid. |
On .grid, --grid-gap defaults to var(--spacer-3) and sets the space between tracks. For .grid.grid-auto-fit, --grid-min-column-width defaults to 16rem and sets the preferred minimum column width. Override these variables on the grid container to customize one layout.
Enable grid behavior
Use the .grid class to enable CSS Grid behavior. The grid uses display: grid; and a twelve column template.
<div class="grid">
<div class="col-12">.grid</div>
</div>Add columns
By applying the class col-* with a number between 1 and 12, you can choose the column width.
Below are three columns, each using .col-4. Since the grid has twelve columns, three items with four columns each fill one row.
<div class="grid">
<div class="col-4">.col-4</div>
<div class="col-4">.col-4</div>
<div class="col-4">.col-4</div>
</div>Different column widths
Combine different column widths to create custom layouts.
<div class="grid">
<div class="col-6">.col-6</div>
<div class="col-3">.col-3</div>
<div class="col-3">.col-3</div>
</div>Full width columns
Use .col-12 to make an element span the full grid width.
<div class="grid">
<div class="col-12">.col-12</div>
<div class="col-6">.col-6</div>
<div class="col-6">.col-6</div>
</div>Place columns
Use col-start-* or col-end-* to place an item on one of the grid’s 13 lines. Use col-offset-* to leave 0 to 11 columns before an item; offset 0 resets an earlier offset. Grid line numbering follows the writing direction, so the same classes start from the right in RTL layouts.
<div class="grid">
<div class="col-4 col-offset-2">Offset by two columns</div>
<div class="col-start-8 col-end-13">Between grid lines 8 and 13</div>
</div>Span rows
Use row-span-* to span 1 to 12 rows. Responsive variants can change the span at a breakpoint.
<div class="grid">
<div class="col-6 row-span-1 row-span-md-2">Spans two rows from md</div>
<div class="col-6">Item</div>
<div class="col-6">Item</div>
</div>Responsive grid
Responsive classes apply from their minimum width upward. Use .col-{breakpoint}-{n} for column spans and insert the breakpoint before the number for placement or row spans: .col-start-md-2, .col-end-md-13, .col-offset-md-2 or .row-span-md-2. All families support sm, md, lg, xl and xxl; see Breakpoints for their widths. Larger active breakpoints win regardless of class order in the markup.
Below the md breakpoint, .col-12 applies and each item takes the full width. From md and up, .col-md-4 applies and the items are shown as three columns.
<div class="grid">
<div class="col-12 col-md-4">.col-12 .col-md-4</div>
<div class="col-12 col-md-4">.col-12 .col-md-4</div>
<div class="col-12 col-md-4">.col-12 .col-md-4</div>
</div>Reset an earlier offset with .col-offset-0 or a responsive variant such as .col-offset-lg-0. For example, this item moves two columns inward from md upward:
<div class="grid">
<div class="col-12 col-md-4 col-offset-0 col-offset-md-2">Responsive placement</div>
</div>Recipes
Responsive layout example
Use a wider main area beside a sidebar, followed by two equally sized summary areas. All four items stack below md; larger screens use an eight/four split for the first row and a six/six split for the second. Keep the source order meaningful when the layout stacks.
<div class="grid">
<div class="col-12 col-md-8">Main content</div>
<div class="col-12 col-md-4">Sidebar</div>
<div class="col-12 col-md-6">Summary</div>
<div class="col-12 col-md-6">Summary</div>
</div>Auto-fit columns
Use this layout for a collection of cards. Add .grid-auto-fit when the number of columns should follow the available width instead of the twelve-column tracks. Each column is at least --grid-min-column-width wide and grows to fill the row. The default minimum is 16rem; narrow containers still fit a single column without horizontal overflow. This example reduces the preferred minimum to 12rem. Leave out .col-* classes here so each item occupies one auto-fit column.
<div class="grid grid-auto-fit" style="--grid-min-column-width: 12rem">
<div>Auto-fit item</div>
<div>Auto-fit item</div>
<div>Auto-fit item</div>
</div>