Skip to content

Scrollbar ​

Used to replace the browser's native scrollbar.

Basic usage ​

Use height property to set the height of the scrollbar, or if not set, it adapts according to the parent container height.

Horizontal scroll ​

When the element width is greater than the scrollbar width, the horizontal scrollbar is displayed.

Max height ​

The scrollbar is displayed only when the element height exceeds the max height.

Manual scroll ​

Use setScrollTop and setScrollLeft methods can control scrollbar manually.

Infinite scroll ​

end-reached is triggered when the scrollbar reaches the end. It can be used as an infinite scroll.

API ​

Attributes ​

NameDescriptionTypeDefault
heightheight of scrollbarstring] | number—
max-heightmax height of scrollbarstring] | number—
nativewhether to use the native scrollbar stylebooleanfalse
wrap-stylestyle of wrap containerCSSProperties | CSSProperties[] | string—
wrap-classclass of wrap containerstring—
view-stylestyle of viewCSSProperties | CSSProperties[] | string—
view-classclass of viewstring—
noresizedo not respond to container size changes, if the container size does not change, it is better to set it to optimize performancebooleanfalse
tagelement tag of the viewstringdiv
alwaysalways show scrollbarbooleanfalse
min-sizeminimum size of scrollbarnumber20
idid of viewstring—
rolerole of viewstring—
tabindextabindex of wrap containernumber | string—
distancetrigger end-reached event distance(px)number0

Events ​

NameDescriptionType
zScrolltriggers when scrolling, return distance of scrolling({ scrollLeft: number, scrollTop: number }) => void
end-reachedtriggers when the end of a scroll is triggered(direction: 'top' | 'bottom' | 'left' | 'right') => void

Slots ​

NameDescription
defaultcustomize default content

Exposes ​

NameDescriptionType
handleScrollhandle scroll event() => void
scrollToCoordscrolls to a particular set of coordinates(options: ScrollToOptions | number, yCoord?: number) => void
setScrollTopSet distance to scroll top(scrollTop: number) => void
setScrollLeftSet distance to scroll left(scrollLeft: number) => void
updateupdate scrollbar state manually() => void
wrapRefscrollbar wrap refHTMLDivElement

Released under the MIT License.