Skip to main content
The ScrollBarRenderable provides visual scroll indicators with support for both vertical and horizontal orientations. It includes an interactive slider track and optional arrow buttons for navigation.

Import

Basic Usage

Scroll Properties

The scrollbar manages three key dimensions:
number
Total size of the scrollable content. For vertical scrollbars, this is the total height of content. For horizontal scrollbars, this is the total width.
number
Size of the visible viewport. Determines the thumb size on the slider.
number
Current scroll position (0 to scrollSize - viewportSize). Automatically clamped to valid range.

Props

'vertical' | 'horizontal'
required
Direction of the scrollbar. Controls layout and keyboard navigation.
boolean
default:"false"
Whether to show arrow buttons at the start and end of the scrollbar for navigation.
Omit<ArrowOptions, 'direction'>
Styling options for arrow buttons:
  • foregroundColor - Color of the arrow character
  • backgroundColor - Background color of the arrow button
  • attributes - Text attributes (bold, underline, etc.)
  • arrowChars - Custom characters for arrows (up, down, left, right)
Partial<SliderOptions>
Options passed to the internal slider component. See Slider documentation for available options.
(position: number) => void
Callback fired when scroll position changes through user interaction.
number | null
default:"null"
Custom step size for “step” unit scrolling. Defaults to 1 if not set.

Methods

scrollBy()

Scroll by a delta amount with different units:
Parameters:
  • delta (number) - Amount to scroll (can be negative)
  • unit (ScrollUnit) - One of:
    • "absolute" - Scroll by exact pixels (default)
    • "viewport" - Multiply delta by viewport size
    • "content" - Multiply delta by total content size
    • "step" - Multiply delta by scrollStep value

resetVisibilityControl()

Reset automatic visibility behavior. By default, the scrollbar hides when content fits in viewport.

Keyboard Navigation

The scrollbar responds to keyboard events when focused:

Examples

Vertical Scrollbar with Arrows

Horizontal Scrollbar

Auto-hiding Scrollbar

Custom Scroll Steps

Child Components

The ScrollBarRenderable contains three child components:

slider

A SliderRenderable instance that provides the draggable thumb and track.
See Slider for full slider API.

startArrow / endArrow

Arrow buttons for navigation (up/left and down/right).

Events

{ position: number }
Fired when scroll position changes through user interaction (dragging slider, clicking arrows, or keyboard navigation).

Notes

  • The scrollbar automatically hides when scrollSize <= viewportSize unless visibility is manually controlled
  • Scroll position is automatically clamped to valid range [0, scrollSize - viewportSize]
  • Mouse interactions on arrows include hold-to-repeat behavior
  • The component is focusable by default for keyboard navigation

Source

View the full source code at packages/core/src/renderables/ScrollBar.ts:19