Protected against bots by Yandex SmartCaptcha. Data processing policy
Checkbox
A checkbox: on, off and (optionally) "indeterminate". The checkbox
does not store a value
itself: it shows
value
and reports a tap through
onChanged
; the markup author writes the new value into state.
Type:
leaf
@agree:false
Checkbox value:$agree onChanged:(value){agree = value}
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
value
|
bool | — |
Whether the checkbox is checked. With
tristate
, an empty value means "indeterminate"
|
tristate
|
bool | false | Third state — "indeterminate" |
onChanged
|
callback | — |
Called on tap, receives the new value in
value
:
(value){…}
.
Without it the checkbox is disabled
(grey, cannot be tapped)
|
activeColor
|
color | — | Color of the checked checkbox |
checkColor
|
color | — | Color of the check mark |
focusColor
|
color | — | Highlight color on focus (app only) |
hoverColor
|
color | — | Highlight color on hover (app only) |
Nested structures
#shape
,
#side
,
#visualDensity
#shape
— the shape (for example,
#shape rounded
with its own
#borderRadius
),
#side
— the border,
#visualDensity
— the density (size of the tappable area).
@done:true
Checkbox value:$done activeColor:#4f46e5 checkColor:#ffffff onChanged:(value){done = value}
#shape rounded
#borderRadius circular 4
Examples
Accepting the terms
@agree:false
Row spacing:8
Checkbox value:$agree onChanged:(value){agree = value}
Text "I agree to the terms"
Checkbox with a third state
@all:false
Checkbox value:$all tristate:true onChanged:(value){all = value}
Differences between the app and the site
- The checkbox looks the same on the site and in the app (it is drawn by Material rules, not by the browser).
-
focusColorandhoverColorare not read on the site. -
A
CheckboxwithoutonChangedis grey and inactive in both.
Bad practices
Checkbox without onChanged
// BAD — the checkbox is disabled: it cannot be tapped
Checkbox value:true
// GOOD
@checked:true
Checkbox value:$checked onChanged:(value){checked = value}