Skip to content

A scrollbar you control.

Replace the scrollbar of any element, or of the whole page. Vanilla JS, no dependencies, vertical and horizontal.

01

Three modes, one option.

Pick how much the library does with mode. Keyboard, anchors, find-in-page and screen readers keep working in all of them, because the real scroll is never replaced.

  • native

    The default. Native scrolling with the system bar hidden and a custom thumb that follows it and can be dragged.

  • css

    Only scrollbar-width and scrollbar-color. The system bar stays, tinted with CSS variables. No thumb, no listeners.

  • simulated

    Like native, plus smooth wheel scrolling: the real scrollTop is eased towards a target with lerp. This page uses it.

02

Both axes.

Set axis to 'y', 'x' or 'both'. With both, the tracks leave the corner free. The strip below scrolls horizontally with its own thumb.

Oneaxis: 'x'
Twostyle: 'rail'
Threemode: 'native'
FourminThumbSize: 32
Fivewidth: 8
Sixdrag the thumb

03

Replace the page scrollbar.

Pass element: 'body' and the library listens to window and measures document.scrollingElement. The track is a fixed overlay on top of the page and does not reserve space. destroy() brings the system bar back.

You are looking at it: the system bar on this page is hidden, and the thumb at the right edge is this library in simulated mode with style: 'thin' and autoHide: true. On touch devices the page keeps its native overlay bars.

04

Install and start.

Import the class and the optional default stylesheet, then create an instance.