-
Notifications
You must be signed in to change notification settings - Fork 11
Checkbox
George Atkinson edited this page Dec 19, 2020
·
6 revisions
A widget that allows the user to make a binary choice between two mutually exclusive options.
Checkbox::new(checked).build(state, parent, |builder| builder);
where checked
is a bool determining the initial state of the checkbox, true
for checked and false
for unchecked.
The default icon used for the checked state is a checkmark (\u{2713} in the Entypo font), and no icon for the unchecked state. The icons used for the checked and unchecked states can be set via the with_icon_checked(icon)
and with_icon_unchecked(icon)
functions respectively, where icon
is the desired Unicode character code for the icon from the Entypo font.
A checkbox has an element ID of checkbox
. The style when checked can be modified using the :checked
pseudoclass.
checkbox {
width: 20px;
height: 20px;
background-color: white;
border-width: 2px;
border-color: black;
border-radius: 3px;
}
checkbox:checked {
background-color: #3669c9;
border-color: #3669c9;
color: white;
}
-
CheckboxEvent::Checked
- emitted by the checkbox when switching from unchecked to checked states. -
CheckboxEvent::Unchecked
- emitted by the checkbox when switching from checked to unchecked states.
-
CheckboxEvent::Check
- sets the checkbox to a checked state. -
CheckboxEvent::Uncheck
- sets the checkbox to a unchecked state. -
CheckboxEvent::Switch
- switches the checkbox from its current state to the other, i.e. checked -> unchecked, unchecked -> checked.
A checkbox has no built-in animations.