Switch

Binary on/off on bits-ui Switch. The thumb rides a snappy spring between positions and collapses to an instant snap under reduced-motion — pair with a Label.

Install

import { Switch } from '$lib/components/ui/switch';

States

Sizes

Two-way bound

API reference

Inherits bits-ui Switch.Root props via spread. The thumb translateX is spring-animated — honors prefers-reduced-motion automatically.

PropTypeDescription
boolean (bindable)Current on/off state. Two-way bindable.
'sm' | 'default'Controls track and thumb dimensions via the --switch-track-* tokens.
booleanDisables the control and drops opacity to 50%.
(checked: boolean) => voidFired when the checked state changes.
HTMLButtonElement | nullTwo-way-bindable element reference.
stringMerged onto the root via tailwind-merge.