class RatatuiRuby::Widgets::Scrollbar
Visualizes the scroll state of a viewport.
Content overflows. Users get lost in long lists without landmarks. They need to know where they are and how much is left.
This widget maps your context. It draws a track and a thumb, representing your current position relative to the total length.
Overlay it on top of lists, paragraphs, or tables to provide spatial awareness.
Example
Run the interactive demo from the terminal:
ruby examples/widget_scrollbar/app.rb
Attributes
Style of the start symbol.
Symbol rendered at the start of the track (e.g., arrow).
Optional wrapping block.
Total items or lines in the content.
Style of the end symbol.
Symbol rendered at the end of the track (e.g., arrow).
Direction of the scrollbar.
:vertical (default, alias for :vertical_right), :horizontal (alias for :horizontal_bottom), :vertical_left, :vertical_right, :horizontal_top, or :horizontal_bottom.
Current scroll offset (index).
Maps to Ratatui’s ScrollbarState::get_position() (new in 0.30.0).
Base style applied to the entire widget.
Style of the position indicator (thumb).
Symbol used to represent the current position indicator.
Style of the filled track area.
Symbol used to represent the empty space of the scrollbar.
Public Class Methods
Source
# File lib/ratatui_ruby/widgets/scrollbar.rb, line 114 def initialize( content_length:, position:, orientation: :vertical, thumb_symbol: "█", thumb_style: nil, track_symbol: nil, track_style: nil, begin_symbol: nil, begin_style: nil, end_symbol: nil, end_style: nil, style: nil, block: nil ) super( content_length: Integer(content_length), position: Integer(position), orientation:, thumb_symbol:, thumb_style:, track_symbol:, track_style:, begin_symbol:, begin_style:, end_symbol:, end_style:, style:, block: ) end
Creates a new Scrollbar.
content_length-
Integer.
- position
-
Integer.
- orientation
-
Symbol (default:
:vertical). thumb_symbol-
String (default:
"█"). thumb_style-
Style(optional). track_symbol-
String (optional).
track_style-
Style(optional). begin_symbol-
String (optional).
begin_style-
Style(optional). end_symbol-
String (optional).
end_style-
Style(optional). - style
-
Style(optional). - block
-
Block(optional).
