pub struct Tabs { /* private fields */ }Expand description
An interactive TabBar over a TabView: give it labeled content and the
current selection; it lays the bar across the top and the active content
below. Selection is external (selected + on_change) — the parent keeps
it in ctx.state.
ⓘ
let tab = ctx.state(0usize);
let t = tab.clone();
Tabs::new(tab.get(), move |i| t.set(i))
.tab("Elements", elements_view())
.tab("Network", network_view())Implementations§
Source§impl Tabs
impl Tabs
pub fn new( selected: usize, on_change: impl Fn(usize) + Send + Sync + 'static, ) -> Self
pub fn tab( self, label: impl Into<String>, content: impl Widget + 'static, ) -> Self
pub fn bar_height(self, h: 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 default 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.
pub fn font_size(self, s: f32) -> Self
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 scrollable(self, on: bool) -> Self
pub fn scrollable(self, on: bool) -> Self
Size each tab to its natural label width and let the bar scroll horizontally instead of squeezing every tab into the available width — for a long/variable-count tab list.
Trait Implementations§
Source§impl Widget for Tabs
impl Widget for Tabs
Source§fn layout(&self, ctx: &LayoutCtx<'_>) -> Size
fn layout(&self, ctx: &LayoutCtx<'_>) -> Size
Measure under
ctx.constraints and return a size within them. Read moreSource§fn children(&self) -> Children<'_>
fn children(&self) -> Children<'_>
Declare this widget’s children. Drives every default below.
Source§fn flex_factor(&self) -> f32
fn flex_factor(&self) -> f32
Flex weight inside Row/Column. Wrappers are transparent by default.
Auto Trait Implementations§
impl !RefUnwindSafe for Tabs
impl !UnwindSafe for Tabs
impl Freeze for Tabs
impl Send for Tabs
impl Sync for Tabs
impl Unpin for Tabs
impl UnsafeUnpin for Tabs
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<W> FocusApi for W
impl<W> FocusApi for W
Source§fn focus_node(self, node: FocusNode) -> WithFocus<Self>
fn focus_node(self, node: FocusNode) -> WithFocus<Self>
Attach a focus node. This enables focus-ring rendering and explicit
neighbor wiring.