cosmic::iced_widget

Module checkbox

source
Expand description

Checkboxes can be used to let users make binary choices.

§Example

use iced::widget::checkbox;

struct State {
   is_checked: bool,
}

enum Message {
    CheckboxToggled(bool),
}

fn view(state: &State) -> Element<'_, Message> {
    checkbox("Toggle me!", state.is_checked)
        .on_toggle(Message::CheckboxToggled)
        .into()
}

fn update(state: &mut State, message: Message) {
    match message {
        Message::CheckboxToggled(is_checked) => {
            state.is_checked = is_checked;
        }
    }
}

Checkbox drawn by iced_wgpu Show toggle controls using checkboxes.

Structs§

Enums§

Traits§

Functions§

  • A danger checkbox; denoting a negative toggle.
  • A primary checkbox; denoting a main toggle.
  • A secondary checkbox; denoting a complementary toggle.
  • A success checkbox; denoting a positive toggle.

Type Aliases§