pub fn toggle_button(state: impl Fn() -> bool + 'static) -> ToggleButton
Expand description
A reactive toggle button
When the button is toggled by clicking or dragging the widget an update will be
sent to the ToggleButton::on_toggle
handler.
See also ToggleButtonClass
, ToggleHandleBehavior
and the other toggle button styles that can be applied.
By default this toggle button has a style class of ToggleButtonClass
applied with a default style provided.
Styles:
background color: style::Background
Toggle color: style::Foreground
inner switch inset: ToggleButtonInset
inner switch (circle) size/radius: ToggleButtonCircleRad
toggle button switch behavior: ToggleButtonBehavior
/ ToggleHandleBehavior
An example using RwSignal
:
use floem::reactive::{SignalGet, SignalUpdate};
let state = floem::reactive::create_rw_signal(true);
floem::views::toggle_button(move || state.get())
.on_toggle(move |new_state| state.set(new_state));