Gutters are the padding between your columns, used to responsively space and align content in the Bootstrap grid system.
Quick reference
Class | Properties |
---|---|
.g-0 | --bs-gutter-x: 0; --bs-gutter-y: 0; |
.g-1 | --bs-gutter-x: 0.25rem; --bs-gutter-y: 0.25rem; |
.g-2 | --bs-gutter-x: 0.5rem; --bs-gutter-y: 0.5rem; |
.g-3 | --bs-gutter-x: 0.75rem; --bs-gutter-y: 0.75rem; |
.g-4 | --bs-gutter-x: 1rem; --bs-gutter-y: 1rem; |
.g-5 | --bs-gutter-x: 1.25rem; --bs-gutter-y: 1.25rem; |
.g-6 | --bs-gutter-x: 1.5rem; --bs-gutter-y: 1.5rem; |
.g-7 | --bs-gutter-x: 1.75rem; --bs-gutter-y: 1.75rem; |
.g-8 | --bs-gutter-x: 2rem; --bs-gutter-y: 2rem; |
.g-9 | --bs-gutter-x: 2.25rem; --bs-gutter-y: 2.25rem; |
.g-10 | --bs-gutter-x: 2.5rem; --bs-gutter-y: 2.5rem; |
.gx-0 | --bs-gutter-x: 0; |
.gx-1 | --bs-gutter-x: 0.25rem; |
.gx-2 | --bs-gutter-x: 0.5rem; |
.gx-3 | --bs-gutter-x: 0.75rem; |
.gx-4 | --bs-gutter-x: 1rem; |
.gx-5 | --bs-gutter-x: 1.25rem; |
.gx-6 | --bs-gutter-x: 1.5rem; |
.gx-7 | --bs-gutter-x: 1.75rem; |
.gx-8 | --bs-gutter-x: 2rem; |
.gx-9 | --bs-gutter-x: 2.25rem; |
.gx-10 | --bs-gutter-x: 2.5rem; |
.gy-0 | --bs-gutter-y: 0; |
.gy-1 | --bs-gutter-y: 0.25rem; |
.gy-2 | --bs-gutter-y: 0.5rem; |
.gy-3 | --bs-gutter-y: 0.75rem; |
.gy-4 | --bs-gutter-y: 1rem; |
.gy-5 | --bs-gutter-y: 1.25rem; |
.gy-6 | --bs-gutter-y: 1.5rem; |
.gy-7 | --bs-gutter-y: 1.75rem; |
.gy-8 | --bs-gutter-y: 2rem; |
.gy-9 | --bs-gutter-y: 2.25rem; |
.gy-10 | --bs-gutter-y: 2.5rem; |
container
and row
elements.How they work
Gutters are the gaps between column content, created by horizontal
padding
. We setpadding-right
andpadding-left
on each column, and use negativemargin
to offset that at the start and end of each row to align content.Gutters start at
1.5rem
(24px
) wide. This allows us to match our grid to the padding and margin spacers scale.Gutters can be responsively adjusted. Use breakpoint-specific gutter classes to modify horizontal gutters, vertical gutters, and all gutters.
Horizontal gutters
.gx-*
classes can be used to control the horizontal gutter widths. The .container
or .container-fluid
parent may need to be adjusted if larger gutters are used too to avoid unwanted overflow, using a matching padding utility.
For example, in the following example we’ve increased the padding with .px-5
:
<div class="container">
<div class="row gx-5">
<div class="col">
Custom column padding
</div>
<div class="col">
Custom column padding
</div>
</div>
</div>
An alternative solution is to add a wrapper around the .row
with the .overflow-hidden
class:
<div class="container overflow-hidden">
<div class="row gx-5">
<div class="col">
Custom column padding
</div>
<div class="col">
Custom column padding
</div>
</div>
</div>
Vertical gutters
.gy-*
classes can be used to control the vertical gutter widths. Like the horizontal gutters, the vertical gutters can cause some overflow below the .row
at the end of a page. If this occurs, you add a wrapper around .row
with the .overflow-hidden
class:
<div class="container overflow-hidden">
<div class="row gy-5">
<div class="col-6">
Custom column padding
</div>
<div class="col-6">
Custom column padding
</div>
<div class="col-6">
Custom column padding
</div>
<div class="col-6">
Custom column padding
</div>
</div>
</div>
Horizontal & vertical gutters
.g-*
classes can be used to control the horizontal gutter widths, for the following example we use a smaller gutter width, so there won’t be a need to add the .overflow-hidden
wrapper class.
<div class="container">
<div class="row g-3">
<div class="col-6">
Custom column padding
</div>
<div class="col-6">
Custom column padding
</div>
<div class="col-6">
Custom column padding
</div>
<div class="col-6">
Custom column padding
</div>
</div>
</div>
Row columns gutters
Gutter classes can also be added to row columns. In the following example, we use responsive row columns and responsive gutter classes.
<div class="container text-center bg-striped-purple px-0">
<div class="row row-cols-2 row-cols-lg-5 g-1 g-lg-3">
<div class="col">
Row column
</div>
<div class="col">
Row column
</div>
<div class="col">
Row column
</div>
<div class="col">
Row column
</div>
.....
</div>
</div>
No gutters
The gutters between columns in our predefined grid classes can be removed with .g-0
. This removes the negative margin
s from .row
and the horizontal padding
from all immediate children columns.
Need an edge-to-edge design? Drop the parent .container
or .container-fluid
and add .mx-0
to the .row
to prevent overflow.
In practice, here’s how it looks. Note you can continue to use this with all other predefined grid classes (including column widths, responsive tiers, reorders, and more).
<div class="row g-0">
<div class="col-sm-6 col-md-8">.col-sm-6 .col-md-8</div>
<div class="col-6 col-md-4">.col-6 .col-md-4</div>
</div>
Breakpoints and media queries
All gutter utilities that supports responsive at specific breakpoints, using the following format g*-{breakpoint}-{*}
for xs
, sm
, md
, lg
, xl
, and xxl
.
Here are all the support classes:
.g-sm-0
.g-sm-1
.g-sm-2
- ……