Components
Switch
Accessible on/off toggle with label and description, controlled or uncontrolled.
Switch toggles a boolean setting. It manages focus and aria-checked for you.
Example
Preview
Receive an email when a report finishes.
import { Switch } from '@officina/ui';
import { useState } from 'react';
function Example() {
const [on, setOn] = useState(true);
return <Switch checked={on} onChange={setOn} label="Email notifications" />;
}API
| Prop | Type | Default | Description |
|---|---|---|---|
| checked | boolean | — | Controlled on/off state. |
| description | string | — | Secondary helper text under the label. |
| disabled | boolean | — | Disable interaction and dim the control. |
| invalid | boolean | — | Marks the field invalid for validation styling and `aria-invalid`. |
| label | string | — | Visible label rendered beside the switch. |
| name | string | — | Form field name, for native form submission / form libraries. |
| onChange | (checked: boolean) => void | — | Called with the new boolean state when toggled. |
| required | boolean | — | Marks the field as required for validation styling and `aria-required`. |