pub struct TabBar { /* private fields */ }Expand description
A horizontal tab bar with an animated sliding underline under the
selected tab. Interactive (mouse + touch) when .on_change is wired.
Fully customizable (D094): every color/size has a builder; unset colors
resolve from the active theme (surface/on_surface/primary/outline),
so the bar adapts to light/dark and custom themes out of the box. The
underline slides between tabs with the theme’s animation curve by default.
Implementations§
Source§impl TabBar
impl TabBar
pub fn new() -> Self
pub fn tab(self, t: Tab) -> Self
pub fn selected(self, i: usize) -> Self
pub fn height(self, h: f32) -> Self
pub fn font_size(self, s: f32) -> Self
Sourcepub fn background(self, c: Color) -> Self
pub fn background(self, c: Color) -> Self
Bar background — theme surface if unset.
Sourcepub fn active_color(self, c: Color) -> Self
pub fn active_color(self, c: Color) -> Self
Selected-tab label color — theme on_surface if unset.
Sourcepub fn inactive_color(self, c: Color) -> Self
pub fn inactive_color(self, c: Color) -> Self
Unselected-tab label color — a muted on_surface if unset.
Sourcepub fn indicator_color(self, c: Color) -> Self
pub fn indicator_color(self, c: Color) -> Self
Sliding-underline color — theme primary if unset.
Sourcepub fn border_color(self, c: Color) -> Self
pub fn border_color(self, c: Color) -> Self
Bottom-divider color — theme outline if unset.
Sourcepub fn animated(self, on: bool) -> Self
pub fn animated(self, on: bool) -> Self
Turn the sliding-underline animation off (on by default).
Sourcepub fn on_change(self, f: impl Fn(usize) + Send + Sync + 'static) -> Self
pub fn on_change(self, f: impl Fn(usize) + Send + Sync + 'static) -> Self
Make the bar interactive: f(index) fires on tap of tab index.
Sourcepub fn scrollable(self, on: bool) -> Self
pub fn scrollable(self, on: bool) -> Self
Size each tab to its natural label width instead of dividing the bar
equally — for many/long tabs that need horizontal scrolling. Wrap the
bar in a ScrollView (or use Tabs::scrollable, which does this for
you) so overflow is actually reachable, not just clipped.
Trait Implementations§
Source§impl Widget for TabBar
impl Widget for TabBar
Source§fn layout(&self, ctx: &LayoutCtx<'_>) -> Size
fn layout(&self, ctx: &LayoutCtx<'_>) -> Size
ctx.constraints and return a size within them. Read more