Contents

Components

Switch

An on-off setting that takes effect the moment you flip it.

Props
import { Switch } from "@sideby/ui/switch";

<Switch id="captions" />
<label for="captions">Captions on my screen</label>

When to use it

A switch changes a setting right away, with no Save button: captions on, sound effects off. If the change only happens after the person confirms something, use a checkbox inside a form instead. If there are more than two choices, use a toggle group.

States

The track is grey and the thumb sits left when off. When on, the track fills with the ring colour and the thumb slides right, so the position says it as clearly as the colour does. A disabled switch fades to half opacity and ignores the pointer.

On and disabled
import { Switch } from "@sideby/ui/switch";

<Switch id="sync-alerts" checked />
<label for="sync-alerts">Tell me when I drift</label>

<Switch id="host-only" disabled />
<label for="host-only">Only the host can pause</label>

Bind checked to read or set the value: bind:checked. For a form, give it a name and Bits UI renders a hidden checkbox input alongside it.

Accessibility

  • It renders a button with role="switch" and aria-checked, so screen readers announce it as a switch that is on or off.
  • Space toggles it. Tab moves to it and shows the ring outline.
  • The label is required. Use a visible label whose for matches the switch id, so clicking the words flips it too and the switch has a name. A switch with no visible label needs an aria-label, but a visible one is almost always better.
  • The hit area reaches a little beyond the track, so it stays easy to hit on a phone.

Copy

Label the setting, not the action: Captions on my screen, not “Turn on captions”. The switch itself already says on or off, so the label should read true in both positions. Keep it to a short phrase and leave the explanation to a description underneath when one is needed.