Switch
Toggle switch for binary on/off settings. Built on Radix UI Switch.
Import
import { Switch } from '@kikumi3n/ui';
Usage
<Switch label="Dark mode" />
<Switch label="Notifications" defaultChecked />
<Switch label="Disabled" disabled />
Controlled
const [enabled, setEnabled] = useState(false);
<Switch label="Feature flag" checked={enabled} onChange={setEnabled} />
API
| Prop | Type | Default | Description |
|---|---|---|---|
label | string | — | Label text |
checked | boolean | — | Controlled state |
defaultChecked | boolean | — | Uncontrolled initial state |
onChange | (checked: boolean) => void | — | Change handler |
disabled | boolean | false | Disable interaction |
name | string | — | Form field name |
Accessibility
Built on Radix UI Switch:
role="switch"witharia-checkedSpace/Enterto toggle- Label click toggles switch