Skip to main content

TabItem

Struct TabItem 

Source
#[non_exhaustive]
pub struct TabItem { pub key: SharedString, pub label: SharedString, pub trigger: Option<AnyElement>, pub content: Option<AnyElement>, pub is_disabled: bool, pub separator: bool, pub width: Option<Pixels>, pub height: Option<Pixels>, pub padding_x: Option<Pixels>, }
Expand description

One tab: key + label + panel content.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§key: SharedString

Stable key identifying the tab.

§label: SharedString

Visible text and accessible name of the tab.

§trigger: Option<AnyElement>

Replacement content for the segment trigger itself; the label text is not rendered when it is set. label stays the tab’s accessible name — an svg or icon div child carries no accessible name of its own.

§content: Option<AnyElement>

Content shown in the panel when the tab is selected.

§is_disabled: bool

Tabs.Tab.isDisabled — removes this tab from activation and the roving keyboard stops without disabling its siblings.

§separator: bool

<Tabs.Separator /> inside this tab. v3 made the hairline between segments opt-in per tab in 3.0.0-beta.12, replacing the automatic pseudo-element and the hideSeparator prop it deleted.

§width: Option<Pixels>

Fixed segment width; None keeps the content-hugging box. Set with TabItem::width.

§height: Option<Pixels>

Fixed segment height; None keeps the size step’s tab height. Set with TabItem::height.

§padding_x: Option<Pixels>

Fixed horizontal padding; None keeps the size step’s tab padding. Set with TabItem::padding_x.

Implementations§

Source§

impl TabItem

Source

pub fn new(key: impl Into<SharedString>, label: impl Into<SharedString>) -> Self

Creates a tab from a key and a label.

Source

pub fn trigger(self, el: impl IntoElement) -> Self

Renders this element as the segment trigger instead of the label text.

This is how the icon-only segmented controls in the reference application are built: every trigger stays the same tab box with its id, hit area, hover, focus ring and keyboard activation, while the content becomes an icon. The trigger is presentational — keep it a plain svg() or div() so presses keep reaching the tab — and svg() does not inherit the tab’s text_color, so set it explicitly. label is still the accessible name; an icon child carries none.

Source

pub fn content(self, el: impl IntoElement) -> Self

Sets the panel content of the tab.

Source

pub fn is_disabled(self, value: bool) -> Self

Sets whether the tab is disabled (v3 Tabs.Tab.isDisabled).

Source

pub fn separator(self) -> Self

Composes a Tabs.Separator into this tab: a hairline before it.

Source

pub fn width(self, w: impl Into<Pixels>) -> Self

Fixes the segment’s width in both variants, beating the box the tab would otherwise hug its content into. This is the reference capture toolbar’s TabsTrigger className="size-8": a square 32px segment whose icon is narrower than the box. The sliding indicator measures the fixed box, so its geometry follows the override exactly.

An explicit width also wins over Tabs::full_width for this tab alone — its siblings still divide the remaining width equally — and replaces the vertical list’s 80px minimum, which would otherwise clamp a narrow segment back up.

Not a v3 prop; it stands in for the className a caller passes to Tabs.Tab.

Source

pub fn height(self, h: impl Into<Pixels>) -> Self

Fixes the segment’s height in both variants, replacing the size step’s tab height (32px on the pinned Md, 28px on Sm) instead of flooring it. The box stays fixed, so a wrapped label keeps painting its extra lines past it exactly as it does at the pinned height.

Not a v3 prop; it stands in for the className a caller passes to Tabs.Tab.

Source

pub fn padding_x(self, p: impl Into<Pixels>) -> Self

Replaces the size step’s horizontal padding (px-4 on the pinned Md box, px-3 on Sm). 0 means no horizontal padding — the fixed icon segment whose whole box is already sized by TabItem::width and TabItem::height.

Not a v3 prop; it stands in for the className a caller passes to Tabs.Tab.

Trait Implementations§

Source§

impl Disableable for TabItem

Source§

fn is_disabled(self, disabled: bool) -> Self

isDisabled — whether the component is disabled.

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more