Skip to main content

Switch

An on/off toggle for settings that apply immediately.

Signature
Density
Viewport
Theme and light/dark are set in the top bar
Live demo
Open ↗

When 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​

PropTypeRequiredDescription
isSelectedboolean—
defaultSelectedboolean—
isDisabledboolean—
onChange(isSelected: boolean, e: React.ChangeEvent) => void—
iconOnReact.ReactNode—Icon shown on the thumb when ON (e.g. a moon for dark mode).
iconOffReact.ReactNode—Icon shown on the thumb when OFF (e.g. a sun for light mode).
childrenReact.ReactNode—
classNamestring—