iced::widget

Module toggler

Expand description

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;
        }
    }
}

Structs§

Enums§

Traits§

Functions§

Type Aliases§