Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Scrollbar

A draggable bar used to control scroll position.

Scrollbar is usually created internally by ScrollView, but can also be used directly in custom views.

When To Use It

Use Scrollbar directly only when building custom scroll containers or advanced scroll interactions. For standard scrolling layouts, use ScrollView and let it manage scrollbar construction and synchronization.

Constructing a Scrollbar

Scrollbar::new(
	cx,
	scroll_value,
	visible_ratio,
	Orientation::Vertical,
	|cx, value| cx.emit(ScrollEvent::SetY(value)),
)
.scroll_to_cursor(true);

Constructor:

Scrollbar::new(cx, value, ratio, orientation, callback)

  • value: scroll progress 0.0..=1.0
  • ratio: visible viewport ratio for thumb sizing
  • orientation: horizontal or vertical
  • callback: receives updated scroll progress while dragging/jumping

Scrollbar Modifiers

ModifierTypeDescriptionDefault
scroll_to_cursorimpl Res<bool>Drag/thumb jumps relative to cursor on press.false

Components and Styling

SelectorDescription
scrollbarRoot scrollbar element.
scrollbar.horizontalHorizontal scrollbar class.
scrollbar.verticalVertical scrollbar class.
scrollbar .thumbDraggable thumb element.

Accessibility

When using direct Scrollbar instances, ensure keyboard and focus behavior of the parent scroll container remains accessible and discoverable.