#[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
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.key: SharedStringStable key identifying the tab.
label: SharedStringVisible 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: boolTabs.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
impl TabItem
Sourcepub fn new(key: impl Into<SharedString>, label: impl Into<SharedString>) -> Self
pub fn new(key: impl Into<SharedString>, label: impl Into<SharedString>) -> Self
Creates a tab from a key and a label.
Sourcepub fn trigger(self, el: impl IntoElement) -> Self
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.
Sourcepub fn content(self, el: impl IntoElement) -> Self
pub fn content(self, el: impl IntoElement) -> Self
Sets the panel content of the tab.
Sourcepub fn is_disabled(self, value: bool) -> Self
pub fn is_disabled(self, value: bool) -> Self
Sets whether the tab is disabled (v3 Tabs.Tab.isDisabled).
Sourcepub fn width(self, w: impl Into<Pixels>) -> Self
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.
Sourcepub fn height(self, h: impl Into<Pixels>) -> Self
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.
Sourcepub fn padding_x(self, p: impl Into<Pixels>) -> Self
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
impl Disableable for TabItem
Source§fn is_disabled(self, disabled: bool) -> Self
fn is_disabled(self, disabled: bool) -> Self
isDisabled — whether the component is disabled.Auto Trait Implementations§
impl !RefUnwindSafe for TabItem
impl !Send for TabItem
impl !Sync for TabItem
impl !UnwindSafe for TabItem
impl Freeze for TabItem
impl Unpin for TabItem
impl UnsafeUnpin for TabItem
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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