Class: RatatuiRuby::Widgets::Tabs
- Inherits:
-
Object
- Object
- RatatuiRuby::Widgets::Tabs
- Includes:
- CoerceableWidget
- Defined in:
- lib/ratatui_ruby/widgets/tabs.rb
Overview
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//app.rb
Instance Method Summary collapse
-
#initialize(titles: [], selected_index: 0, block: nil, divider: nil, highlight_style: nil, style: nil, padding_left: 0, padding_right: 0) ⇒ Tabs
constructor
Creates a new Tabs widget.
-
#width ⇒ Object
Returns the total width of the tabs.
Methods included from CoerceableWidget
Constructor Details
#initialize(titles: [], selected_index: 0, block: nil, divider: nil, highlight_style: nil, style: nil, padding_left: 0, padding_right: 0) ⇒ Tabs
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).
72 73 74 75 76 77 78 79 80 81 82 83 |
# 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 |
Instance Method Details
#width ⇒ Object
Returns the total width of the tabs.
86 87 88 |
# File 'lib/ratatui_ruby/widgets/tabs.rb', line 86 def width RatatuiRuby._tabs_width(self) end |
