This page as markdown: /scroller.md · Index for agents: /llms.txt · Everything in one file: /llms-full.txt

Scroller

Status: stable

Scroll container that fades its leading/trailing edges when content overflows. Tracks scroll position to toggle the fades.

Keywords: scroller, overflow, horizontal scroll, carousel

Usage

Use Scroller to create a contained overflow region for content that naturally extends beyond the viewport.

Best practices

Props

Name Type Default Description
orientation "vertical" | "horizontal" "vertical" "vertical" scrolls and fades top/bottom; "horizontal" scrolls and fades left/right.
wheelScroll boolean true On a horizontal Scroller, let a vertical mouse wheel scroll it sideways. Ignored when vertical. Turn it off only if the region is inside something that owns the wheel itself (a map, a canvas).
smoothWheel boolean false Ease mouse-wheel steps toward their target, on either axis: the inertia a smooth-scroll library such as Lenis adds, scoped to this region. Off by default, so the region scrolls natively, off the main thread; easing needs a non-passive wheel listener that runs before every scroll. Only a mouse wheel is eased; trackpads and touch keep their own momentum, keys and scrollbar drags stay native, and reduced motion (the OS preference or MotionProvider) turns it off. Anything else that moves the region (scrollIntoView, a stick-to-bottom chat) stops the easing at once. For a scroll container of your own, useSmoothWheel() returns the same behaviour as a ref callback.
label string — Accessible name for the scroll region. The region takes focus, so it should say what it contains; without one a screen reader announces an unnamed group.
viewportClassName string — Classes for the inner element that actually scrolls. Narrow on purpose — className is what you want almost always. This is for the few utilities that only mean something on the scrolling box: snap-x, scroll-smooth, scroll-p-*.
...div props ComponentPropsWithRef<'div'> — Everything except className/style spreads onto the SCROLLING element — role, id, aria-*, data-* and event handlers all describe the thing that scrolls, and CommandMenu relies on it to make this component its listbox. ref and onScroll likewise address the scroller, and compose with the component's own.

Variants

Tokens used

ring

Motion

Accessibility

Related

Examples

Vertical with overflow

import { Scroller } from "@sableui/react"

<Scroller label="Projects" className="h-64"><ul className="space-y-2 p-4">{items.map((item) => (<li key={item.id} className="text-body-sm">{item.title}</li>))}</ul></Scroller>

Capped, scrolls past the cap

import { Scroller } from "@sableui/react"

<Scroller label="Versions" className="max-h-80 rounded-md border border-border"><ul className="divide-y divide-border">{versions.map((v) => (<li key={v.id} className="px-3 py-2 text-body-sm">{v.label}</li>))}</ul></Scroller>

Horizontal

import { Scroller } from "@sableui/react"

<Scroller orientation="horizontal" label="Recent covers" className="w-full"><div className="flex gap-3 p-4">{covers.map((src) => (<img key={src} src={src} alt="" className="h-32 w-32 rounded-lg object-cover" />))}</div></Scroller>

Snap points on the scrolling box

import { Scroller } from "@sableui/react"

<Scroller orientation="horizontal" label="Covers" className="w-full rounded-lg border border-border" viewportClassName="snap-x snap-mandatory scroll-smooth"><div className="flex gap-3 p-4">{covers.map((src) => (<img key={src} src={src} alt="" className="h-32 w-32 snap-start rounded-lg object-cover" />))}</div></Scroller>