Overview
AScrollable is a widget that can display an infinite amount of content with scrollbars. It supports vertical scrolling, horizontal scrolling, or both, with customizable scrollbar appearance and behavior.
Constructor
scrollable::Scrollable::new
Scrollable with the given content.
scrollable::Scrollable::with_direction
Scrollable with a specific scrolling direction.
Builder Methods
Direction
horizontal
direction
Identity
id
Layout
width
height
Anchoring
anchor_top / anchor_bottom
anchor_left / anchor_right
anchor_x / anchor_y
Anchor enum:
Scrollbar Configuration
spacing
Behavior
on_scroll
auto_scroll
Appearance
style
Scrollbar
Scrollbar Methods
Status
Style
Examples
Basic Vertical Scrollable
Horizontal Scrollable
Both Directions
With Size Constraints
With Scroll Event Handler
Anchored to Bottom (Chat)
With Embedded Scrollbar
Hidden Scrollbar
With Auto-scroll
Custom Scrollbar Style
Custom Scrollbar Configuration
Virtualized List Pattern
Chat Window
Code Editor Viewport
Interaction
- Mouse wheel - Scroll vertically (or horizontally with Shift)
- Touch - Drag to scroll
- Scrollbar drag - Click and drag the scrollbar handle
- Middle mouse button - Auto-scroll (if enabled)
- Keyboard - Arrow keys when content is focused
Performance Tips
- Use
anchor_bottom()for chat-like interfaces - Consider virtualization for very long lists
- Use
on_scrollsparingly for expensive operations - Embedded scrollbars (
spacing()) take layout space - Hidden scrollbars still allow scrolling
Related
Container
For non-scrollable containers
Layout Guide
Learn about layout strategies
