Checkboxes allow the user to select one or more items from a set.
Note that checkboxes are usually used in conjunction with form fields. Refer to FormField for more information.
import Material.Checkbox as Checkbox
type Msg
= Changed
main =
Checkbox.checkbox
(Checkbox.config
|> Checkbox.setState (Just Checkbox.unchecked)
|> Checkbox.setOnChange Changed
)Default configuration of a checkbox
Specify a message when the user changes a checkbox
State of a checkbox
Specify a checkbox' state
A checkbox may be in checked, unchecked or indeterminate state.
Specify whether a checkbox is disabled
Disabled checkboxes cannot be interacted with and have no visual interaction effect.
Specify additional attributes
Checkbox view function
To set the state of a checkbox, use its setState configuration option.
Checkbox.checkbox
(Checkbox.config
|> Checkbox.setState (Just Checkbox.checked)
)Checked state
Unchecked state
To set the state of a checkbox, use its setState configuration option.
Checkbox.checkbox
(Checkbox.config
|> Checkbox.setState (Just Checkbox.indeterminate)
)Indeterminate state
To disable a checkbox, use its setDisabled configuration option. Disabled
checkboxes cannot be interacted with and have no visual interaction effect.
Checkbox.checkbox
(Checkbox.config |> Checkbox.setDisabled True)
Configuration of a checkbox