Switch

A boolean toggle. Built on Radix Switch.

Import

import { Switch } from '@aspect/react';

Usage

<Switch aria-label="Notifications" />
<Switch defaultChecked aria-label="Enabled" />

Controlled

const [on, setOn] = useState(false);
<Switch checked={on} onCheckedChange={setOn} />;

Props

| Prop | Type | Default | Description | | ----------------- | ---------------------------- | ------- | -------------------------- | | checked | boolean | — | Controlled state | | defaultChecked | boolean | — | Uncontrolled initial state | | onCheckedChange | (checked: boolean) => void | — | Change handler | | disabled | boolean | false | Disables the switch |

Guidelines

Do:

Don't: