Skip to main content

TabBar

Struct TabBar 

Source
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

Source

pub fn new() -> Self

Source

pub fn tab(self, t: Tab) -> Self

Source

pub fn selected(self, i: usize) -> Self

Source

pub fn height(self, h: f32) -> Self

Source

pub fn font_size(self, s: f32) -> Self

Source

pub fn background(self, c: Color) -> Self

Bar background — theme surface if unset.

Source

pub fn active_color(self, c: Color) -> Self

Selected-tab label color — theme on_surface if unset.

Source

pub fn inactive_color(self, c: Color) -> Self

Unselected-tab label color — a muted on_surface if unset.

Source

pub fn indicator_color(self, c: Color) -> Self

Sliding-underline color — theme primary if unset.

Source

pub fn border_color(self, c: Color) -> Self

Bottom-divider color — theme outline if unset.

Source

pub fn animated(self, on: bool) -> Self

Turn the sliding-underline animation off (on by default).

Source

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.

Source

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 Default for TabBar

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Widget for TabBar

Source§

fn layout(&self, ctx: &LayoutCtx<'_>) -> Size

Measure under ctx.constraints and return a size within them. Read more
Source§

fn paint(&self, ctx: &mut PaintCtx<'_>)

Record draw commands for ctx.rect. Read more
Source§

fn children(&self) -> Children<'_>

Declare this widget’s children. Drives every default below.
Source§

fn flex_factor(&self) -> f32

Flex weight inside Row/Column. Wrappers are transparent by default.
Source§

fn into_element(self) -> Element
where Self: Sized + 'static,

Wrap this widget in an Element so it can be returned from Component::build().

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<W> FocusApi for W
where W: Widget + Send + Sync + 'static,

Source§

fn focus_node(self, node: FocusNode) -> WithFocus<Self>

Attach a focus node. This enables focus-ring rendering and explicit neighbor wiring.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<W> HeroApi for W
where W: Widget + Send + Sync + 'static,

Source§

fn hero_tag(self, tag: impl Into<String>) -> Hero<Self>

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<W> OverlayApi for W
where W: Widget + Send + Sync + 'static,

Source§

fn dropdown( self, open: Atom<bool>, content: impl Fn() -> BoxedWidget + Send + Sync + 'static, ) -> WithOverlay<Self>

Source§

fn sheet( self, open: Atom<bool>, content: impl Fn() -> BoxedWidget + Send + Sync + 'static, ) -> WithOverlay<Self>

Source§

fn dialog( self, open: Atom<bool>, content: impl Fn() -> BoxedWidget + Send + Sync + 'static, ) -> WithOverlay<Self>

Source§

fn rich_tooltip( self, content: impl Fn() -> BoxedWidget + Send + Sync + 'static, ) -> WithOverlay<Self>

Source§

fn toast( self, open: Atom<bool>, content: impl Fn() -> BoxedWidget + Send + Sync + 'static, ) -> WithOverlay<Self>

Source§

impl<W> PressApi for W
where W: Widget + Send + Sync + 'static,

Source§

fn on_press(self, f: impl Fn() + Send + Sync + 'static) -> Pressable<Self>

Source§

fn on_long_press( self, f: impl Fn() + Send + Sync + 'static, ) -> LongPressable<Self>

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<W> WidgetExt for W
where W: Widget + 'static,

Source§

fn tooltip(self, label: impl Into<String>) -> Tooltip

Show label while the pointer hovers this widget.