1. Reference
  2. Forms and input

<switch>

A Material on/off toggle with an optional label; name= holds true or false.

Forms and input
switch.ham
<column style="w-full gap-8">
    <switch name="wifi"
            label="Wi-Fi"
            checked="true"
            color="teal-600"/>
    <switch name="bluetooth"
            label="Bluetooth"
            color="teal-600"/>
    <text @text="$wifi ? 'Connected to Home_5G' : 'Wi-Fi is off'"
          style="muted"></text>
</column>
The snippet drawn by Hype Apps on a phone, in light mode The snippet drawn by Hype Apps on a phone, in dark mode
This snippet as Hype Apps draws it on a phone. It follows this page's light or dark theme.

Attributes

NameWhat it doesDefault
checked Initial toggle state
boolean
false
color Active color
color
label Toggle label
string
name Variable name for form scoping
string

Readings

NameWhat it does
checked The same as value, named after checked=.
value Whether it is on, live.

Any tag also takes gestures: @on.tap, @on.longpress, @on.doubletap and @on.swipeleft (and right, up and down). @click runs on a tap too.

This page is also Markdown, and all of HAM is in llms.txt.