pub fn toggler<'a, Message, Theme, Renderer>(
is_checked: bool,
) -> Toggler<'a, Message, Theme, Renderer>
Expand description
Creates a new Toggler
.
Togglers let users make binary choices by toggling a switch.
§Example
use iced::widget::toggler;
struct State {
is_checked: bool,
}
enum Message {
TogglerToggled(bool),
}
fn view(state: &State) -> Element<'_, Message> {
toggler(state.is_checked)
.label("Toggle me!")
.on_toggle(Message::TogglerToggled)
.into()
}
fn update(state: &mut State, message: Message) {
match message {
Message::TogglerToggled(is_checked) => {
state.is_checked = is_checked;
}
}
}