Skip to content

Spacing

The spacing system provides utility classes for margin and padding using a consistent scale based on 1rem.

Pattern: .util-margin-<side>-<size>

SideDescription
topTop margin only
bottomBottom margin only
leftLeft margin only
rightRight margin only
allAll four sides
vertTop and bottom
horizLeft and right

The gray area represents the container. The gap between the container edge and the blue box shows the margin applied by the utility class.

Equal lg (1.5rem) margin on all four sides of the inner element.

.util-margin-all-lg

<div class="util-background-light-gray" style="overflow: hidden">
<div class="util-margin-all-lg util-background-odyssey util-pad-all-md">
<p>.util-margin-all-lg</p>
</div>
</div>

An xl (2.5rem) margin applied only to the top and bottom. Notice the blue box extends to the container edges on the left and right because no horizontal margin is applied.

.util-margin-vert-xl

<div class="util-background-light-gray" style="overflow: hidden">
<div class="util-margin-vert-xl util-background-odyssey util-pad-all-md">
<p>.util-margin-vert-xl</p>
</div>
</div>

An xl (2.5rem) margin applied only to the left and right. The blue box touches the top and bottom of the container because no vertical margin is applied.

.util-margin-horiz-xl

<div class="util-background-light-gray" style="overflow: hidden">
<div class="util-margin-horiz-xl util-background-odyssey util-pad-all-md">
<p>.util-margin-horiz-xl</p>
</div>
</div>

Pattern: .util-pad-<side>-<size>

Uses the same sides and sizes as margin.

.util-pad-all-xl

<div class="util-pad-all-xl util-background-odyssey">
<p>.util-pad-all-xl</p>
</div>

Both margin and padding classes use the same set of size values:

KeyValue
none0
xs0.25rem
sm0.5rem
md1rem
lg1.5rem
xl2.5rem
xxl3.5rem

All spacing classes support responsive breakpoint suffixes:

<div class="util-margin-top-md util-margin-top-xl@md util-margin-top-xxl@lg">
Responsive spacing
</div>
SuffixMin-width
@sm30rem (480px)
@md50rem (800px)
@lg60rem (960px)
@xl80rem (1280px)
@printPrint media