Koala logo Design
Esc
No matches for “
↑↓ navigate open Esc close
Components Switches

Switches

Binary toggle — rectangular track + rectangular thumb, backed by a real checkbox so it round-trips through ASP.NET model binding without JavaScript. The standard 5px radius, no pill shape. For 2+ option segmented selection, reach for <koala-segmented-control> instead.

<koala-switch>

Canonical

Backed by a real <input type="checkbox"> so it round-trips through ASP.NET model binding without JavaScript. The hidden false-default pattern is handled internally — an unticked box still posts a value.

States

2 states
Off
On

Props

7 attributes
Attribute Values Notes
forModelExpression?Property-bound switches. Mutually exclusive with name.
namestring?Form field name for dynamic-name switches (inside loops). Pair with checked.
checkedboolInitial checked state — required when using name.
valuestringCheckbox value. Defaults to "true"; set for multi-select patterns.
labelstring?Optional inline label rendered next to the switch.
x-modelstring?Wires the underlying checkbox to a parent Alpine state variable.
x-on:changestring?Alpine handler that runs when the switch flips. Useful for auto-submit-on-change.

Do & don't

Do Use the switch for binary on/off — settings flags, "include X", visibility toggles.
A switch shown next to three mutually-exclusive options
Don't Don't reach for a switch when you have 2+ mutually-exclusive choices — use <koala-segmented-control> instead.