The toggle switch is used to switch between two mutually exclusive states (on / off), commonly representing whether a feature is enabled. The style reproduces the WinUI 3 / Windows App SDK ToggleSwitch: a self-built track + thumb that fully reproduces the WinUI feel of 「click to toggle / drag the thumb to the end / keyboard toggle / thumb enlarges on hover / thumb widens in place on active (pill shaped)」. Movement only uses transform, the easing animation is only enabled while toggling; the thumb only changes size within the rail and inherently cannot leave the track area, and no small backward jump occurs at the moment of toggling either.
v-model binds a boolean. Clicking anywhere on the switch toggles it; dragging the thumb past halfway drops it to the target end, and less than halfway springs it back; the keyboard Space / Enter toggles, ◀ turns off, and ▶ turns on.
Wi-Fi: true · Bluetooth: false · VPN: true
The standard WinUI ToggleSwitch track is 40×20 (medium). The web side additionally provides small (32×16) and large (48×24), keeping a 2:1 ratio; travel (thumb travel 16 / 20 / 24) aligns with Fluent spacing L / XL / XXL respectively.
Reproduces the WinUI three-layer structure: #header top description row, #on-content / #off-content cross-fading in the same cell to the right of the track, and the default slot as the row label (also semantically visible text).
Hold and drag the thumb left or right and it follows the pointer; on release, if it passed the midpoint it lands on the other end, otherwise it springs back to its original state — consistent with WinUI. During a drag only will-change: transform is enabled (never resident in the idle state); after releasing, an easing curve smoothly animates the thumb to its end point.
Wi-Fi: true · Bluetooth: false · VPN: true
When disabled, it is not interactive, and the track, the thumb, and the text all fall to the …Disabled tier.
When inside a <form> with name passed, a hidden native <input type="checkbox"> is added, and the enabled result is submitted with the form (value is the submitted value, default "on").
Wi-Fi: true · Bluetooth: false · VPN: true
| Prop | Type | Default | Description |
|---|---|---|---|
modelValue | boolean | false | Whether on (v-model) |
disabled | boolean | false | Whether disabled |
size | 'small' | 'medium' | 'large' | 'medium' | Size (medium aligns with WinUI 40×20) |
name | string | — | Form submission name, paired with a hidden native input |
value | string | 'on' | The value submitted when on |
label | string | — | Accessible name (defaults to content/title text) |
| Slot | Description |
|---|---|
default | Row label (semantic name) |
header | Top title row (WinUI Header) |
on-content | Text shown when on (cross-fade) |
off-content | Text shown when off (cross-fade) |
Movement only uses
transform: translateX(calc(var(--travel) * progress)), never touchingleft/right; there is no residentwill-changein the normal state, enabled only during dragging; the animation duration comes from Fluentduration*, the easing fromcurveEasyEase(Max), andprefers-reduced-motionis respected.