class RatatuiRuby::Widgets::Tabs
Displays a tab bar for navigation.
Screen real estate is limited. You cannot show everything at once. Segregating content into views is necessary for complex apps.
This widget separates dimensions. It displays a row of titles, indicating which view is active.
Use it at the top of your interface to switch between major modes or contexts.
Example
Run the interactive demo from the terminal:
ruby examples/widget_tabs/app.rb
Attributes
Optional wrapping block.
Separator string between tabs.
Style for the selected tab title.
Left padding for the tabs area. Accepts Integer (number of spaces), String, or Line for styled content.
Right padding for the tabs area. Accepts Integer (number of spaces), String, or Line for styled content.
Index of the active tab.
Base style for the tabs area.
Tab titles (Array of Strings).
Public Class Methods
Source
# File lib/ratatui_ruby/widgets/tabs.rb, line 72 def initialize(titles: [], selected_index: 0, block: nil, divider: nil, highlight_style: nil, style: nil, padding_left: 0, padding_right: 0) super( titles:, selected_index: Integer(selected_index), block:, divider:, highlight_style:, style:, padding_left: (padding_left.is_a?(Text::Line) || padding_left.is_a?(String)) ? padding_left : Integer(padding_left), padding_right: (padding_right.is_a?(Text::Line) || padding_right.is_a?(String)) ? padding_right : Integer(padding_right) ) end
Creates a new Tabs widget.
- titles
-
Array of Strings/Lines.
selected_index-
Integer (default: 0).
- block
-
Block(optional). - divider
-
String (optional).
highlight_style-
Style(optional). - style
-
Style(optional). padding_left-
String, Line, or anything that responds to
to_i(default: 0). padding_right-
String, Line, or anything that responds to
to_i(default: 0).
Public Instance Methods
Source
# File lib/ratatui_ruby/widgets/tabs.rb, line 86 def width RatatuiRuby._tabs_width(self) end
Returns the total width of the tabs.
