Skip to main content

tab_line

Function tab_line 

Source
pub fn tab_line(tabs: &[(&str, bool)], theme: &Theme) -> Line<'static>
Expand description

Builds a horizontal tab-bar Line from a list of (label, is_active) pairs.

Active tab uses Theme::tab_active, inactive tabs use Theme::tab_inactive. Tabs are separated by two spaces. A leading and trailing space is added so the line reads cleanly inside a block title.

The returned Line is 'static (all content is owned) so it can be used freely as a block title without lifetime concerns.

§Example

let title = tab_line(&[
    ("Browse",    matches!(tab, Tab::Browse)),
    ("Favorites", matches!(tab, Tab::Favorites)),
    ("History",   matches!(tab, Tab::History)),
], &theme);