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.

Attributes

NameDescriptionTypeDefault
heightheight of scrollbarstring / number
max-heightmax height of scrollbarstring / number
nativewhether to use the native scrollbar stylebooleanfalse
wrap-stylestyle of wrap containerstring / object CSSProperties | CSSProperties[] | string[]
wrap-classclass of wrap containerstring
view-stylestyle of viewstring / object CSSProperties | 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

Events

NameDescriptionType
scrolltriggers when scrolling, return distance of scrolling({ scrollLeft: number, scrollTop: number }) => void

Slots

NameDescription
defaultcustomize default content

Exposes

NameDescriptionType
handleScrollhandle scroll event() => void
scrollToscrolls 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 refRef<HTMLDivElement>
Last Updated:
Contributors: Tam Mai