Foundation ComponentReact 18 & 19Zero Runtime CSS
Switch
An immediate on or off choice, built on a native form control.
Interactive preview
Usage
import { Switch, Label } from "@devvy-ui/react";
<Label><Switch name="updates" defaultChecked /> Product updates</Label>API reference
Native HTML attributes, className, style and a forwarded ref are supported. Component-specific props:
| Prop | Type | Default | Description |
|---|---|---|---|
| checked / defaultChecked | boolean | false | Controlled or initial checked state. |
| onChange | ChangeEventHandler | — | Read event.target.checked. |
| disabled | boolean | false | Disables interaction. |
| name / value | string | — / on | Native checked form submission. |
Accessibility & behavior
Platform Behavior & Guidelines
Uses input type="checkbox" with role="switch". Space toggles it. A stable label should describe the preference, without changing when toggled.
Source ownership
Add the audited implementation directly into your repository with the CLI:
node /path/to/devvy-ui/packages/cli/src/cli.mjs add switchMake the source yours.
Start from the canonical implementation used by the package and registry. Change the code, keep the MIT notice, and build the behavior your project needs.
Switch.tsxREACT / TSX
Edit your own copy. Downloaded source uses your changes; the component preview above uses the shipped version. Run the source installer first to include shared helpers.