Playground
Size
Disabled
Basic Switch
Simple Toggle
Interactive toggle without an inline label.
With Label
Inline Label
Implicit wrapping for simple mouse clicking target enhancement.
Sizes
States
Loading
Async Setting
Simulates a 1.2s save round-trip before the toggle settles.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| checked | boolean | false | Sets the toggled state of the switch. |
| onChange | (checked: boolean) => void | — | Callback fired when toggle state changes. |
| disabled | boolean | false | Disables interaction and applies visual opacity. |
| loading | boolean | false | Shows a spinner in place of the thumb and blocks interaction — for an async toggle mid-flight. |
| size | "sm" | "md" | "md" | Controls the scale/dimension of the switch track. |
| label | string | — | Optional label rendered to the right of the switch control. |
Usage Guidelines
When to use
- Use for a setting that takes effect immediately on toggle, with no separate Save step — e.g. enabling notifications.
When not to use
- Don't use Switch inside a form that needs an explicit Save/Submit before the change applies — that mismatch confuses users about whether the toggle already did something.
- Don't use Switch for more than two states — that's Segmented Control's job.