Module tabbed

Module tabbed 

Source
Expand description

Render tabs.

This widget doesn’t render the content. Use TabbedState::widget_area to render the selected tab.

use ratatui::buffer::Buffer;
use ratatui::layout::Rect;
use ratatui::text::Text;
use ratatui::widgets::{Block, StatefulWidget, Widget};
use rat_widget::tabbed::{TabPlacement, TabType, Tabbed, TabbedState};

let mut tab = Tabbed::new()
    .tab_type(TabType::Attached)
    .placement(TabPlacement::Top)
    .closeable(true)
    .block(
         Block::bordered()
    )
    .tabs(["Issues", "Numbers", "More numbers"])
    .render(area, buf, &mut state.tabbed);

match state.tabbed.selected() {
    Some(0) => {
        Text::from("... issues ...")
            .render(state.tabbed.widget_area, buf);
    }
    Some(1) => {
        Text::from("... 1,2,3,4 ...")
            .render(state.tabbed.widget_area, buf);
    }
    Some(1) => {
        Text::from("... 5,6,7,8 ...")
            .render(state.tabbed.widget_area, buf);
    }
    _ => {}
}

Structs§

LayoutWidget
Widget for the Layout of the tabs.
Tabbed
A tabbed widget.
TabbedState
State & event-handling.
TabbedStyle
Combined Styles
TabbedWidget
Primary widget for rendering the Tabbed.

Enums§

TabPlacement
Placement relative to the Rect given to render.
TabType
Rendering style for the tabs.

Functions§

handle_events
Handle all events. Text events are only processed if focus is true. Mouse events are processed if they are in range.
handle_mouse_events
Handle only mouse-events.