Switch
switchA control for a setting that takes effect immediately, with a label wired to it for a screen reader. Optional on and off text inside the track, and the thumb travels on a single transform so the motion stays smooth.
import { Switch } from "@/components/forme/switch/switch";
export function SwitchDemo() {
return (
<div className="flex flex-col gap-5">
<div className="flex flex-col gap-3">
<Switch label="Email me about releases" defaultChecked />
<Switch label="Weekly digest" />
<Switch label="Disabled" disabled defaultChecked />
</div>
<div className="flex flex-col gap-3">
<Switch label="Public profile" onLabel="On" offLabel="Off" defaultChecked />
<Switch label="Public profile" onLabel="On" offLabel="Off" />
</div>
</div>
);
}Install
Adds the component, its registry dependencies, and the token stylesheet you import once.
Usage
import { Switch } from "@/components/forme/switch/switch";
<Switch label="Email me when a deploy fails" defaultChecked />When to use
Reach for it
- A setting that takes effect the moment it changes, with no Save button.
Use something else
- Options that are only applied when a form is submitted; use a
Checkbox. - Choosing between two named values that are not on and off — a
SegmentedControlsays both names.
API reference
Read from the source, so it is the API of the file you install. A prop marked * is required.
Switch
A switch, with its label.
| Prop | Type | Default | Description |
|---|---|---|---|
label | React.ReactNode | — | The visible label. Rendered beside the switch and wired to it. |
onLabel | string | — | Text shown inside the track, either side of the thumb. Both are optional. |
offLabel | string | — |
Also takes every prop of Omit<SwitchRootProps, "children">.
Accessibility
- The label is tied with
aria-labelledby, because the switch is a<button>and a<label>may not wrap one.
Motion
- The thumb travels on the standard duration; the track's colour changes at once.
Related


Checkbox
A single choice with a visible label wired to it for a screen reader. Carries a destructive variant for choices that cannot be undone, and the box itself fills with the accent when checked so the state is readable at a glance.
forms

Radio group
A choice of exactly one option, where the group owns the value and the arrow keys travel in the direction the options are laid out. Horizontal and vertical are the same component with an orientation, and a disabled option reads as present but unavailable.
forms

Select
A choice from a list too long for radio buttons. Grouped with labels, an inline check on the selected option, typeahead and arrow-key navigation from the Base UI select primitive, and a trigger that reads as a field rather than as a button so it sits beside inputs without looking wrong.
forms