Overview
TheScrollBoxRenderable extends BoxRenderable to provide scrollable content areas with automatic scrollbar management, viewport culling, and advanced features like sticky scrolling and scroll acceleration.
Basic Usage
Props
Scroll Configuration
boolean
default:"true"
Enable vertical scrolling.
boolean
default:"false"
Enable horizontal scrolling.
boolean
default:"false"
Enable sticky scroll behavior that automatically sticks to edges when new content is added.
'top' | 'bottom' | 'left' | 'right'
Initial sticky position. Requires
stickyScroll: true.ScrollAcceleration
Custom scroll acceleration implementation. Defaults to
LinearScrollAccel(). Also available: MacOSScrollAccel().boolean
default:"true"
Enable viewport culling to only render visible children, improving performance for large lists.
Container Options
ScrollBox is composed of multiple nested containers. You can customize each layer:Scrollbar Configuration
Omit<ScrollBarOptions, 'orientation'>
Options applied to both vertical and horizontal scrollbars.Available properties:
width: Width of the scrollbar (default: 1)showArrows: Show arrow buttons (default: false)trackOptions: Styling for the trackarrowOptions: Styling for arrow buttons
Omit<ScrollBarOptions, 'orientation'>
Options specific to the vertical scrollbar. Overrides
scrollbarOptions.Omit<ScrollBarOptions, 'orientation'>
Options specific to the horizontal scrollbar. Overrides
scrollbarOptions.Padding
Padding props are forwarded to the content container, not the root.
number | `${number}%`
Padding on all sides of the content.
number | `${number}%`
Horizontal padding (left and right).
number | `${number}%`
Vertical padding (top and bottom).
number | `${number}%`
Padding on the top side.
number | `${number}%`
Padding on the right side.
number | `${number}%`
Padding on the bottom side.
number | `${number}%`
Padding on the left side.
Properties
scrollTop
scrollLeft
scrollHeight
Read-only. Total scrollable height.scrollWidth
Read-only. Total scrollable width.Methods
scrollBy(delta, unit?)
Scroll by a specified amount.delta:number | { x: number, y: number }- Amount to scrollunit:'absolute' | 'percentage' | 'page'(default: ‘absolute’)
scrollTo(position)
Scroll to a specific position.add(child, index?)
Add a child element to the scroll content.remove(id)
Remove a child element by ID.focus()
Focus the scrollbox to enable keyboard scrolling.Examples
Basic Vertical Scrolling
Styled Scrollbars
Sticky Scroll (Chat/Log View)
Horizontal Scrolling
Two-Way Scrolling
Custom Scroll Acceleration
Toggling Scrollbar Visibility
Disable Viewport Culling
Keyboard Controls
When a ScrollBox has focus, these keys control scrolling:- Up Arrow / Down Arrow: Scroll by one line
- Page Up / Page Down: Scroll by one page
- Home: Scroll to top
- End: Scroll to bottom
- Shift + Scroll Wheel: Switch horizontal/vertical scroll direction
Architecture
ScrollBox is composed of nested containers:- Root: The outermost container, configure with
rootOptions - Wrapper: Contains viewport and horizontal scrollbar
- Viewport: The visible area with clipping
- Content: Holds all children, translates to create scroll effect
- Scrollbars: Positioned outside the viewport
Performance
Viewport Culling
By default, ScrollBox only renders children that are visible in the viewport. This dramatically improves performance for large lists:Sticky Scroll Behavior
Sticky scroll automatically keeps the view “stuck” to an edge when new content is added:- Bottom stick: Useful for chat/logs - stays at bottom as messages arrive
- Top stick: Useful for reverse-chronological feeds
- Automatically disables when user manually scrolls away
- Re-enables when scrolled back to the sticky edge
Notes
- ScrollBox inherits all props from Box via
rootOptions - Padding is applied to the content container, not the root
- Scrollbars are automatically shown/hidden based on content size
- Mouse wheel scrolling works when hovering over the ScrollBox
- Shift + mouse wheel switches scroll direction (vertical ↔ horizontal)
- Auto-scrolling during drag selection is supported
For simple non-scrollable containers, use Box instead.