Function cosmic::iced_widget::checkbox
source · pub fn checkbox<'a, Message, Theme, Renderer>(
label: impl Into<String>,
is_checked: bool,
) -> Checkbox<'a, Message, Theme, Renderer>
Expand description
Creates a new Checkbox
.
§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;
}
}
}