ComponentsForms
Switch
A toggle control for on/off states.
Overview
A switch toggles a single setting on or off, taking effect immediately. Pair it
with a Label describing what it controls.
$ npx morpha-ui add switchExamples
With label
Disabled
Installation
Morpha UI components are distributed via the Morpha CLI (coming in a later
step): npx morpha-ui add switch. In the meantime, since this is the base
shadcn component, you can also add it directly:
npx shadcn@latest add switchAPI Reference
Prop
Type
Accessibility
- The underlying Radix primitive exposes
role="switch"and thecheckedstate. - Associate a
<Label htmlFor>with the switchidso its purpose is announced. - Keyboard: focus with Tab, toggle with Space or Enter.