Switch
An on/off toggle for settings that apply immediately.
Signature
Density
Viewport
Theme and light/dark are set in the top barWhen to use
An on/off toggle for settings that apply immediately.
Accessibility
Exposes role="switch" with aria-checked; toggled with Space. Pair the icon variant with a real label.
Install and import
npx shadcn@latest add @prism/switch
import { Switch } from '@/components/prism/Switch';
In a no-build prototype, read it from the bundle instead: const { Switch } = window.PrismDesignSystem_39d121;
Props
| Prop | Type | Required | Description |
|---|---|---|---|
isSelected | boolean | — | |
defaultSelected | boolean | — | |
isDisabled | boolean | — | |
onChange | (isSelected: boolean, e: React.ChangeEvent) => void | — | |
iconOn | React.ReactNode | — | Icon shown on the thumb when ON (e.g. a moon for dark mode). |
iconOff | React.ReactNode | — | Icon shown on the thumb when OFF (e.g. a sun for light mode). |
children | React.ReactNode | — | |
className | string | — |