pub struct Toggle(/* private fields */);Expand description
A control that toggles between on and off states.
Toggle displays a switch with an optional label. It’s commonly used for settings that can be turned on or off.
§Layout Behavior
With a label: Toggle expands horizontally to fill available space, placing the label on the left and switch on the right. Without a label: Toggle is content-sized (just the switch).
§Examples
ⓘ
// Simple toggle with label
toggle("Wi-Fi", &is_enabled)
// Toggle without label
Toggle::new(&dark_mode)
// In a settings list
vstack((
toggle("Notifications", ¬ifications),
toggle("Sound", &sound),
))Implementations§
Trait Implementations§
Source§impl ConfigurableView for Toggle
impl ConfigurableView for Toggle
Source§impl From<ToggleConfig> for Toggle
impl From<ToggleConfig> for Toggle
Source§fn from(value: ToggleConfig) -> Self
fn from(value: ToggleConfig) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for Toggle
impl !RefUnwindSafe for Toggle
impl !Send for Toggle
impl !Sync for Toggle
impl Unpin for Toggle
impl !UnwindSafe for Toggle
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more