Browse documentation
Reference / Interactivity
Scroll behavior
Choose instant or smooth movement for navigation and programmatic scrolling. Manual wheel and touch scrolling use browser input behavior.
Working example
Focus the first checkbox, then press Tab to reach the signature.
Set the class on the element that actually scrolls. For document-level anchor navigation, put it on the html element.
<div tabindex="0" role="region" aria-label="Proof notes" class="h-24 overflow-y-auto border p-2 motion-safe:scroll-smooth">
<label class="block"><input type="checkbox" class="accent-black"> Approve the sheet</label>
<p class="mt-3 h-24">Focus the first checkbox, then press Tab to reach the signature.</p>
<label class="block"><input type="checkbox" class="accent-black"> Sign the proof</label>
</div>Class reference
| Class | CSS declarations |
|---|---|
scroll-auto | scroll-behavior: auto; |
scroll-smooth | scroll-behavior: smooth; |
motion-safe:scroll-smooth | scroll-behavior: smooth; |
motion-reduce:scroll-auto | scroll-behavior: auto; |
View full generated CSS
.scroll-auto {
scroll-behavior: auto;
}
.scroll-smooth {
scroll-behavior: smooth;
}
@media (prefers-reduced-motion: no-preference) {
.motion-safe\:scroll-smooth {
scroll-behavior: smooth;
}
}
@media (prefers-reduced-motion: reduce) {
.motion-reduce\:scroll-auto {
scroll-behavior: auto;
}
}