Skip to content

Gap

gap-* sets the space between children of a flex, grid, or multi-column container. It belongs to the layout, so it survives wrapping and never collapses like a margin.

gap-0 through gap-24 use the spacing scale and read the --gap knob:

Class gap
gap-0 0
gap-1 0.25rem
gap-2 0.5rem
gap-3 0.75rem
gap-4 1rem
gap-6 1.5rem
gap-8 2rem
gap-12 3rem
gap-16 4rem
gap-24 6rem
<div class="d-flex gap-4" style="--gap: 0.75rem">…</div>

gap-* is compact-only. For a responsive gap, use a layout primitive or a media query.

Prefer gap over margins on children. A gap is a property of the container: it applies between items only, works with flex-wrap, and cannot collapse. A margin belongs to each child and has to be removed from the last one.

<div class="d-flex flex-wrap gap-3">
<span>One</span>
<span>Two</span>
<span>Three</span>
</div>

For a vertical stack of prose, see Space Between. For the layout primitives that encode gap for you, see Layout Primitives.

The class is the markup shorthand. The same style in a component stylesheet:

.cluster {
display: flex;
gap: var(--nc-space-4);
}

The Sass subpackage exposes the same value: nc.nc-space(4). See Sass subpackage.

A breakpoint is the same declaration inside a media query; you do not need a second class.