Switch
An immediate on/off toggle for settings that apply straight away.
- Forms
- 1 file
- 1 npm package
- Accessibility notes
Loading the example…
pnpm dlx @dowel-ui/cli add switchnpm packages installed: radix-ui.
import { Switch } from "@/components/ui/switch";Default
States
Settings Row
Animated Toggle
<Switch>
| Prop | Type | Default |
|---|---|---|
iconsIcons drawn inside the thumb, one per state, that turn and crossfade as it moves. Decorative: the state is announced by the switch role. | { checked: ReactNode; unchecked: ReactNode } | — |
variantHow the thumb moves. Opt-in, because both change the thumb's shape: - | "default" | "squash" | "morph" | "default" |
Every prop of Radix UI’s Switch.Root, plus className.
Exposed as role="switch" and toggled with Space or Enter. Needs a visible label tied with htmlFor/id. Do not rely on colour alone to show state — position and the label carry it too. Icons passed to `icons` are aria-hidden decoration; the press squash only runs without a reduced-motion preference.
8/8
checks passed
- Tested — passes
- axe assertion — passes
- Keyboard tested — does not apply
- Storybook examples — passes
- Accessibility documented — passes
- Semantic tokens only — passes
- Motion from tokens — passes
- className merged — passes
- Visible focus — does not apply
- No fixed widths — passes