Scrollbar

Provide styled scroll areas with programmatic scroll control.

Scrollbar

Scroll progress

Read and write percentages from 0–100 with v-model:x and v-model:y, measured against the scrollable range rather than total content size. Bind either axis independently; use @update:y for observation without two-way control. Map the value directly to translation, rotation, opacity, or a CSS variable without an animation dependency. For GSAP, divide by 100 and pass it to a paused timeline’s progress(); create the timeline once rather than on every scroll.

Values retain fractional precision, out-of-range inputs are clamped to 0–100, and non-finite inputs are ignored. An axis without overflow reports 0. Viewport or content resizing preserves the actual pixel position and recalculates the percentage; temporarily hidden viewports retain their last progress and restore it when visible. With noresize, call update() after content changes. Programmatic smooth scrolling continues to report actual progress; observing updates does not initiate another scroll.

Edge fade

Set fade to hint that more content remains beyond a scroll edge. true and "y" cover both vertical edges; "x" covers both horizontal edges. Use top, bottom, left, or right for physical edges and start or end for direction-aware inline edges. The shadcn-style aliases t, b, l, r, s, and e are accepted too. A number is a vertical fade size in pixels, while { direction, size } accepts a CSS length or percentage.

The fade follows actual overflow and scroll position. Content that fits is never masked, and each edge clears as it is reached. The implementation uses Scrollbar’s existing measurements rather than adding another scroll owner.

Outside scrollbars

Set placement="outside" to place both tracks beside the viewport, keeping the thumbs clear of your content. Use gap for track spacing and thickness for track thickness; colors follow the component’s HSL primary tokens.

This example uses max-height: removing items lets the viewport shrink, and tracks appear only on overflowing axes. Outside tracks stay within the component’s footprint, without negative offsets or changes to the parent’s overflow.

Drag a thumb, click a track, or use a wheel or touchpad. Tab into the viewport to scroll with arrow keys. With always disabled, tracks hide after the pointer leaves while their space stays reserved to avoid layout shifts.

Default

Used to replace the browser’s native scrollbar.

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.

API

PROPS

Property
Type
Values
Description
default
Example
More
v-model:x
Number
0–100
Horizontal scroll percentage, 0–100. Zero is inline start (the right edge in RTL); writing a value scrolls to that position.
—
v-model:y
Number
0–100
Vertical scroll percentage, 0–100; writing a value scrolls to that position.
—
placement
String
insideoutside
Custom track placement. outside reserves space beside the viewport; ignored in native mode.
inside
gap
Number
number
Gap in pixels between outside tracks and the viewport. Negative values are clamped to zero.
6
height
String, Number
number
height of scrollbar
—
max-height
String, Number
number
max height of scrollbar
—
native
Boolean
truefalse
whether to use the native scrollbar
false
—
fade
false | true | y | x | top/t | bottom/b | left/l | right/r | start/s | end/e | number | ScrollbarFadeOptions
Scroll-aware content edge fade. `true` uses both vertical edges; a number sets their size in pixels; options select a direction and CSS size.
false
wrap-style
String, Object, Array
CSSPropertiesCSSProperties[]string[]
style of wrap container
—
—
wrap-class
String
string
class of wrap container
—
—
view-style
String, Object, Array
CSSPropertiesCSSProperties[]string[]
style of view container
—
—
view-class
String
string
class of view container
—
—
noresize
Boolean
truefalse
do not respond to container size changes, if the container size does not change, it is better to set it to optimize performance
false
—
tag
string
HTML Tag
element tag of the view
div
—
always
Boolean
truefalse
always show scrollbar
true
—
min-size
Number
—
minimum size of scrollbar
20
—
thickness
Number, String
number
thumb width
6
—

EVENTS

Event
Type
Payload
Description
default
Example
More
update:x
function
(value: number) => void
Emitted when actual scroll percentage changes, including scroll and viewport or content resizing.
—
update:y
function
(value: number) => void
Emitted when actual scroll percentage changes, including scroll and viewport or content resizing.
—
scroll
function
({ scrollLeft: numberscrollTop: number }) => void
triggers when scrolling, return distance of scrolling
—
—

SLOTS

Slot
Description
default
Example
More
default
customize default content
—
—

EXPOSES

Method
Type
Parameters
Description
default
Example
More
handleScroll
function
() => void
handle scroll event
—
—
scrollTo
function
(options: ScrollToOptions | numberyCoord?: number) => void
scrolls to a particular set of coordinates
—
—
setScrollTop
function
(scrollTop: number) => void
Set distance to scroll top
—
—
setScrollLeft
function
(scrollLeft: number) => void
Set distance to scroll left
—
—
update
function
() => void
update scrollbar state manually
—
—
wrapRef
object
Ref HTMLElement
scrollbar wrap ref
—
—
Last Updated: 2026-10-28, 06:17:56 UTC
Copied