Interactivity

Scroll Snap

Utilities for sets viewport lock to certain elements or locations after finished scrolling.


Variant

Active Checked Child-Selection Dark Mode Disabled Expand First-Last-Selection First-Letter Focus Focus-Visible Focus-Within Fullscreen Group-Focus Group-Hover Hover Landscape Light Mode Portrait Reduce-Motion Responsive Selection-Hover Visited

API

classcss
scroll-snap {type} {align}scroll-snap-type: {type};
scroll-snap-align: {align}
classcss
x-mandatoryscroll-snap-type: x mandatory
y-mandatoryscroll-snap-type: y mandatory
classcss
x-proximityscroll-snap-type: x proximity
y-proximityscroll-snap-type: y proximity
classcss
block-mandatoryscroll-snap-type: block mandatory
block-proximityscroll-snap-type: block proximity
classcss
inline-mandatoryscroll-snap-type: inline mandatory
inline-proximityscroll-snap-type: inline proximity
classcss
both-mandatoryscroll-snap-type: both mandatory
both-proximityscroll-snap-type: both proximity
classcss
align-startscroll-snap-align: start
align-centerscroll-snap-align: center
align-endscroll-snap-align: end
align-nonescroll-snap-align: none

Usage

Set the horizontal scroll image gallery. The image snaps to the left container after scrolling.

<div class="scroll-snap x-mandatory align-start ... flex overflow-x-scroll">
<img src="...">
<img src="...">
...
</div>
HTML
.dummy {
@extend
.scroll-snap,
.x-mandatory,
.align-start,
.flex,
.overflow-x-scroll;
}
SCSS

Set the vertical scroll image gallery. The image snaps to the top container after scrolling.

<div class="scroll-snap y-mandatory align-start ... overflow-y-scroll">
<img src="...">
<img src="...">
...
</div>
HTML
.dummy {
@extend
.scroll-snap,
.y-mandatory,
.align-start,
.overflow-y-scroll;
}
SCSS

Set the horizontal and vertical scroll image gallery. The image snaps to the center container after scrolling.

<div class="scroll-snap x-mandatory y-mandatory align-center ... flex flex-wrap overflow-scroll">
<img src="...">
<img src="...">
...
</div>
HTML
.dummy {
@extend
.scroll-snap,
.x-mandatory,
.y-mandatory,
.align-center,
.flex,
.flex-wrap,
.overflow-scroll;
}
SCSS