Skip to content

Switch ​

A binary on/off toggle. Brand-blue when on.

Examples ​

Basic usage ​

moonbit
@sumi.switch(checked=is_on, on_change=set_enabled.map(v => _ => v))
@sumi.switch(checked=is_on, disabled=true)

API ​

switch ​

NameTypeDefaultDescription
checked *Bool—Whether the control is checked (controlled)
on_changeEmit[Bool]—Called when the value changes
disabledBoolfalseBlocks interaction and dims the control
idString—Element id
classString—Extra class names
titleString—Native tooltip title
attrsAttrs—Extra HTML attributes
styleArray[String][]Extra inline styles

* required (labelled) parameter — everything else is optional.