Protected against bots by Yandex SmartCaptcha. Data processing policy
Switch
An on/off switch. Like
Checkbox
, it holds no value: it shows
value
, reports a tap through
onChanged
, and the markup author writes the new value.
Type:
leaf
@enabled:true
Switch value:$enabled onChanged:(value){enabled = value}
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
value
|
bool | false | Whether the switch is on |
onChanged
|
callback | — |
Called on tap, receives the new value in
value
:
(value){…}
.
Without it the switch is disabled
(gray, not tappable)
|
activeThumbColor
|
color | — | Thumb color when on (app only) |
activeTrackColor
|
color | — | Track color when on |
inactiveThumbColor
|
color | — | Thumb color when off (app only) |
inactiveTrackColor
|
color | — | Track color when off (app only) |
focusColor
|
color | — | Highlight color on focus (app only) |
hoverColor
|
color | — | Highlight color on hover (app only) |
Examples
A setting with a label
@notify:false
Row spacing:12
Text "Notifications"
Switch value:$notify onChanged:(value){notify = value}
Custom colors
@dark:true
Switch value:$dark activeThumbColor:#4f46e5 activeTrackColor:#c7d2fe onChanged:(value){dark = value}
Differences between the app and the site
The thumb color has different names:
-
in the app —
activeThumbColor; -
on the site the color of the switched-on thumb is read from
activeColor, whileactiveThumbColor,inactiveThumbColor,inactiveTrackColor,focusColorandhoverColorare not read.
If the colors must match in both builds, write both names:
activeThumbColor:#4f46e5 activeColor:#4f46e5
(the editor may flag the extra one as an unknown parameter for a particular build).
activeTrackColor
works the same everywhere.