pub struct Toggle { /* private fields */ }Expand description
Implementations§
Source§impl Toggle
impl Toggle
Sourcepub const fn variant(self, variant: ToggleVariant) -> Self
pub const fn variant(self, variant: ToggleVariant) -> Self
Set the visual variant
Sourcepub const fn size(self, size: ToggleSize) -> Self
pub const fn size(self, size: ToggleSize) -> Self
Set the size
Sourcepub const fn content_width(self, width: f32) -> Self
pub const fn content_width(self, width: f32) -> Self
Set explicit content area width for custom content.
When using show_ui, this controls the inner width.
If not set, defaults to a square layout (width = height).
Sourcepub fn show(self, ui: &mut Ui, pressed: &mut bool) -> ToggleResponse
pub fn show(self, ui: &mut Ui, pressed: &mut bool) -> ToggleResponse
Show the toggle button
pressed tracks whether the toggle is in the on/off state.
Sourcepub fn show_ui(
self,
ui: &mut Ui,
pressed: &mut bool,
content: impl FnOnce(&mut Ui, &ContentContext),
) -> ToggleResponse
pub fn show_ui( self, ui: &mut Ui, pressed: &mut bool, content: impl FnOnce(&mut Ui, &ContentContext), ) -> ToggleResponse
Show the toggle with custom content instead of a text label.
The closure receives a &mut Ui (with override text color set) and a
ContentContext with the state-dependent color and font size.
§Example
ⓘ
let mut pressed = false;
Toggle::new("")
.variant(ToggleVariant::Outline)
.show_ui(ui, &mut pressed, |ui, ctx| {
// Render an icon using ctx.color
});Auto Trait Implementations§
impl Freeze for Toggle
impl RefUnwindSafe for Toggle
impl Send for Toggle
impl Sync for Toggle
impl Unpin for Toggle
impl UnsafeUnpin for Toggle
impl UnwindSafe for Toggle
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
Mutably borrows from an owned value. Read more