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

Set the class on the element that actually scrolls. For document-level anchor navigation, put it on the html element.

HTML
<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

ClassCSS declarations
scroll-autoscroll-behavior: auto;
scroll-smoothscroll-behavior: smooth;
motion-safe:scroll-smoothscroll-behavior: smooth;
motion-reduce:scroll-autoscroll-behavior: auto;
View full generated CSS
Compiled 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;
  }
}