pub struct Switch { /* private fields */ }Expand description
Material switch. The caller owns the checked state and optional thumb content.
Implementations§
Source§impl Switch
impl Switch
Sourcepub fn new(
id: impl Into<ElementId>,
label: impl Into<SharedString>,
checked: bool,
) -> Self
pub fn new( id: impl Into<ElementId>, label: impl Into<SharedString>, checked: bool, ) -> Self
Creates a controlled switch with an element ID, accessible/visible label, and current checked state.
Sourcepub fn show_label(self, show: bool) -> Self
pub fn show_label(self, show: bool) -> Self
Controls whether the visible label is rendered. Defaults to true.
When false, the constructor’s label remains the accessible name and the trailing gap is omitted.
Sourcepub fn label_content(self, content: impl IntoElement) -> Self
pub fn label_content(self, content: impl IntoElement) -> Self
Replaces the visible label while keeping the constructor’s label as the accessible name.
Sourcepub fn disabled(self, disabled: bool) -> Self
pub fn disabled(self, disabled: bool) -> Self
Disables pointer, keyboard, and accessibility interaction when true.
Sourcepub fn checked_icon(self, icon: impl IntoElement) -> Self
pub fn checked_icon(self, icon: impl IntoElement) -> Self
Sets an icon rendered inside the thumb when checked is true.
Sourcepub fn unchecked_icon(self, icon: impl IntoElement) -> Self
pub fn unchecked_icon(self, icon: impl IntoElement) -> Self
Sets an icon rendered inside the thumb when checked is false.
Sourcepub fn thumb_content(self, content: impl IntoElement) -> Self
pub fn thumb_content(self, content: impl IntoElement) -> Self
Supplies decorative content in the centered 16 px thumb slot. The element takes precedence over the icon preset for this render.
Sourcepub fn colors(self, colors: SwitchColors) -> Self
pub fn colors(self, colors: SwitchColors) -> Self
Overrides track, border, thumb, and thumb-content colors per switch state.
Sourcepub fn track_focus(self, focus: &FocusHandle) -> Self
pub fn track_focus(self, focus: &FocusHandle) -> Self
Uses the caller’s focus handle instead of an internal keyed handle.
Sourcepub fn interaction_source(self, source: &Entity<InteractionSource>) -> Self
pub fn interaction_source(self, source: &Entity<InteractionSource>) -> Self
Reports presentation state to a caller-owned source.
Trait Implementations§
Source§impl IntoElement for Switch
impl IntoElement for Switch
Source§type Element = ViewElement<Switch>
type Element = ViewElement<Switch>
Source§fn into_element(self) -> Self::Element
fn into_element(self) -> Self::Element
Element.Source§fn into_any_element(self) -> AnyElement
fn into_any_element(self) -> AnyElement
AnyElement.Source§impl RenderOnce for Switch
impl RenderOnce for Switch
Source§fn render(self, window: &mut Window, cx: &mut App) -> impl IntoElement
fn render(self, window: &mut Window, cx: &mut App) -> impl IntoElement
Render::render() method
which takes a mutable reference.Auto Trait Implementations§
impl !RefUnwindSafe for Switch
impl !Send for Switch
impl !Sync for Switch
impl !UnwindSafe for Switch
impl Forget for Switch
impl Freeze for Switch
impl Move for Switch
impl Unpin for Switch
impl UnsafeUnpin for Switch
Blanket Implementations§
Source§impl<E> AnimationExt for Ewhere
E: IntoElement + 'static,
impl<E> AnimationExt for Ewhere
E: IntoElement + 'static,
Source§fn with_animation(
self,
id: impl Into<ElementId>,
animation: Animation,
animator: impl Fn(Self, f32) -> Self + 'static,
) -> AnimationElement<Self>where
Self: Sized,
fn with_animation(
self,
id: impl Into<ElementId>,
animation: Animation,
animator: impl Fn(Self, f32) -> Self + 'static,
) -> AnimationElement<Self>where
Self: Sized,
Source§fn with_animations(
self,
id: impl Into<ElementId>,
animations: Vec<Animation>,
animator: impl Fn(Self, usize, f32) -> Self + 'static,
) -> AnimationElement<Self>where
Self: Sized,
fn with_animations(
self,
id: impl Into<ElementId>,
animations: Vec<Animation>,
animator: impl Fn(Self, usize, f32) -> Self + 'static,
) -> AnimationElement<Self>where
Self: Sized,
Source§fn with_spring<T>(
self,
id: impl Into<ElementId>,
animation: SpringAnimation<T>,
animator: impl FnOnce(Self, <T as SpringTarget>::Output) -> Self + 'static,
) -> SpringAnimationElement<Self>
fn with_spring<T>( self, id: impl Into<ElementId>, animation: SpringAnimation<T>, animator: impl FnOnce(Self, <T as SpringTarget>::Output) -> Self + 'static, ) -> SpringAnimationElement<Self>
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> FluentBuilder for Twhere
T: IntoElement,
impl<T> FluentBuilder for Twhere
T: IntoElement,
Source§fn map<U>(self, f: impl FnOnce(Self) -> U) -> Uwhere
Self: Sized,
fn map<U>(self, f: impl FnOnce(Self) -> U) -> Uwhere
Self: Sized,
Source§fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Selfwhere
Self: Sized,
fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Selfwhere
Self: Sized,
Source§fn when_else(
self,
condition: bool,
then: impl FnOnce(Self) -> Self,
else_fn: impl FnOnce(Self) -> Self,
) -> Selfwhere
Self: Sized,
fn when_else(
self,
condition: bool,
then: impl FnOnce(Self) -> Self,
else_fn: impl FnOnce(Self) -> Self,
) -> Selfwhere
Self: Sized,
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 moreSource§impl<T> MaterialElementExt for Twhere
T: IntoElement,
impl<T> MaterialElementExt for Twhere
T: IntoElement,
Source§fn badge_label(self, text: impl Into<SharedString>) -> Badge
fn badge_label(self, text: impl Into<SharedString>) -> Badge
Badge to this element’s upper trailing edge.Source§fn badge_count(self, count: usize, maximum: usize) -> Badge
fn badge_count(self, count: usize, maximum: usize) -> Badge
Badge to this element’s upper trailing edge.Source§fn tooltip(
self,
id: impl Into<ElementId>,
text: impl Into<SharedString>,
) -> Tooltip
fn tooltip( self, id: impl Into<ElementId>, text: impl Into<SharedString>, ) -> Tooltip
Tooltip.Menu.Menu
whose items are built lazily only while the menu is open.Source§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<E> TestTextExt for Ewhere
E: IntoElement,
impl<E> TestTextExt for Ewhere
E: IntoElement,
Source§fn test_text(self, text: impl Into<SharedString>) -> Self::Element
fn test_text(self, text: impl Into<SharedString>) -> Self::Element
test-support, records text each time the element paints.
Otherwise returns the element it builds.Source§fn test_alt_text(self, text: impl Into<SharedString>) -> Self::Element
fn test_alt_text(self, text: impl Into<SharedString>) -> Self::Element
Self::test_text for an image’s alternative text, which
stands in for what the element draws.