Skip to main content

Tabs

Struct Tabs 

Source
pub struct Tabs { /* private fields */ }
Expand description

Tabs component for switching between content sections

§Example

use armas_basic::Tabs;

let mut tabs = Tabs::new(vec!["Account", "Password"])
    .height(24.0)
    .font_size(12.0);
let response = tabs.show(ui);
if response.changed {
    // Tab changed to response.selected
}

Implementations§

Source§

impl Tabs

Source

pub fn new(labels: Vec<impl Into<String>>) -> Self

Create new tabs with labels

Source

pub fn active(self, index: usize) -> Self

Set active tab index

Source

pub const fn animate(self, animate: bool) -> Self

Enable or disable animation

Source

pub const fn width(self, width: f32) -> Self

Set width (0 = fit content, which is the default)

Source

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

Set overall height

Source

pub const fn padding(self, padding: f32) -> Self

Set inner padding

Source

pub const fn list_radius(self, radius: f32) -> Self

Set outer container corner radius

Source

pub const fn trigger_radius(self, radius: f32) -> Self

Set active indicator corner radius

Source

pub const fn trigger_padding_x(self, padding: f32) -> Self

Set horizontal padding inside each tab trigger

Source

pub const fn gap(self, gap: f32) -> Self

Set gap between tabs

Source

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

Set font size

Source

pub fn show(&mut self, ui: &mut Ui) -> TabsResponse

Show the tabs and return the response

Source

pub fn show_ui( &mut self, ui: &mut Ui, count: usize, render_tab: impl Fn(usize, &mut Ui, &ContentContext), ) -> TabsResponse

Show the tabs with custom content for each tab trigger.

The closure receives the tab index, a &mut Ui, and a ContentContext. If width is not set, the tabs use ui.available_width() and distribute tab widths evenly.

§Example
let mut tabs = Tabs::new(Vec::<String>::new()).height(28.0);
let response = tabs.show_ui(ui, 3, |index, ui, ctx| {
    // Render icon + label for tab `index` using ctx.color
    let labels = ["Account", "Password", "Settings"];
    ui.label(labels[index]);
});

Auto Trait Implementations§

§

impl Freeze for Tabs

§

impl RefUnwindSafe for Tabs

§

impl Send for Tabs

§

impl Sync for Tabs

§

impl Unpin for Tabs

§

impl UnsafeUnpin for Tabs

§

impl UnwindSafe for Tabs

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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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<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.