ScrollFrame

A scroll area whose edge fades show only while there is more to see, with quiet scrollbars and optional previous and next buttons.

@patternmode/scrollframe

Scrolled partway on both axes, so both edges fade. At either end that fade goes.

Reference

States and variants

Choose the axes, how scrollbars show, and which edges fade.

  • Vertical

    axes="vertical"
  • Horizontal, no scrollbar

    axes="horizontal" scrollbars="hidden"
  • Both axes, always shown

    axes="both" scrollbars="always"
  • End fade only

    fades="end"
  • Mask over any background

    fadeMode="mask"
  • Previous and next

    controls scrollStep="page"

Install and use

Wrap any list. For custom layouts, compose the parts under ScrollFrame.Root.

npm i @patternmode/scrollframe
import { ScrollFrame } from "@patternmode/scrollframe";
import "@patternmode/scrollframe/styles.css";

<ScrollFrame aria-label="Activity" className="h-96">
  {items.map((item) => (
    <ActivityRow key={item.id} item={item} />
  ))}
</ScrollFrame>

<ScrollFrame axes="horizontal" scrollbars="hidden" controls scrollStep="page">
  {children}
</ScrollFrame>

Core API

ScrollFrame

Base UI-backed scroll container with measured fades and movement controls.

axes
"vertical" | "horizontal" | "both""vertical"Chooses the supported scroll axes.
fades
boolean | "none" | "start" | "end" | "both" | AxisFadeConfigtrueControls measured eased edge fades.
fadeColor
stringCSS color used by the fade overlays.
fadeSize
number | stringSize of the fade overlay along the scroll axis.
scrollbars
"auto" | "always" | "hover" | "hidden""auto"Controls scrollbar visibility; hidden and always keep the scroll plumbing mounted.
controls
boolean | ScrollFrameControlsConfigfalseAdds overflow-aware previous and next movement controls.
dragScroll
boolean | ScrollFrameDragScrollConfigfalseEnables pointer drag scrolling while preserving native scroll and text selection until a drag threshold is crossed.
scrollStep
"page" | number | ((state, axis) => number)"page"Controls movement distance for previous and next controls.

Keyboard and accessibility

What it handles without extra wiring.

aria-label
Names the scroll area. Every example in the README passes one.
Previous, Next
Real buttons that take the focus ring from --ring and scroll one step.
Reduced motion
Fades stop animating and the controls scroll instantly.
Hidden scrollbars
Stay mounted, so wheel and touch scrolling still work.

Package

Package
@patternmode/scrollframe
Version
2.0.9
Needs
react, react-dom
Licence
MIT