Browse documentation
Reference / Interactivity
Scroll snap type
Choose the axis and strictness of scroll snapping. The scroller defines the axis and its children supply snap positions.
Working example
Paper
Carbon
Stone
Scroll the strip horizontally. Mandatory snapping settles on a snap point, while proximity gives the browser latitude near each point.
<div tabindex="0" role="region" aria-label="Snap between paper swatches"
class="flex w-48 max-w-full gap-3 overflow-x-auto border p-2 snap-x snap-mandatory">
<div class="w-32 shrink-0 bg-neutral-100 p-4 snap-center">Paper</div>
<div class="w-32 shrink-0 bg-neutral-800 p-4 text-white snap-center">Carbon</div>
<div class="w-32 shrink-0 bg-neutral-200 p-4 snap-center">Stone</div>
</div>Class reference
| Class | CSS declarations |
|---|---|
snap-none | scroll-snap-type: none; |
snap-x | scroll-snap-type: x var(--mono-snap-strictness, proximity); |
snap-y | scroll-snap-type: y var(--mono-snap-strictness, proximity); |
snap-both | scroll-snap-type: both var(--mono-snap-strictness, proximity); |
snap-proximity | --mono-snap-strictness: proximity; |
snap-mandatory | --mono-snap-strictness: mandatory; |
View full generated CSS
@property --mono-snap-strictness {
syntax: "*";
inherits: false;
}
.snap-both {
scroll-snap-type: both var(--mono-snap-strictness, proximity);
}
.snap-mandatory {
--mono-snap-strictness: mandatory;
}
.snap-none {
scroll-snap-type: none;
}
.snap-proximity {
--mono-snap-strictness: proximity;
}
.snap-x {
scroll-snap-type: x var(--mono-snap-strictness, proximity);
}
.snap-y {
scroll-snap-type: y var(--mono-snap-strictness, proximity);
}