Pixie
View as Markdown

Switch

A two-state on/off toggle.

Props#

NameTypeDefaultDescription
checkedbooleanControlled checked state.
defaultCheckedbooleanfalseUncontrolled initial checked state.
disabledbooleanfalseDisable the switch.
labelstringLabel rendered next to the switch.
onChange((checked: boolean) => void)Change handler — receives the new checked state.

Off#

Show code
Off.stories.tsx
import { Switch } from '../../../src/pixie/Switch.js';

export default () => <Switch label="Email notifications" />;

On#

Show code
On.stories.tsx
import { Switch } from '../../../src/pixie/Switch.js';

export default () => <Switch label="Email notifications" defaultChecked />;

Disabled#

Show code
Disabled.stories.tsx
import { Switch } from '../../../src/pixie/Switch.js';

export default () => <Switch label="Locked setting" disabled defaultChecked />;