Switch
A checkbox with role="switch", drawn as a toggle.
How it helpsIt is still a real checkbox, so it submits with forms and is announced as on or off.
Toggles
export default function Example() {
return (
<>
<div className="flex flex-col gap-3">
<label><input type="checkbox" role="switch" defaultChecked /> Push notifications</label>
<label><input type="checkbox" role="switch" /> Weekly digest</label>
<label><input type="checkbox" role="switch" defaultChecked data-tone="info" /> Auto-categorise</label>
<label><input type="checkbox" role="switch" disabled /> Disabled</label>
</div>
</>
);
}<div class="flex flex-col gap-3">
<label><input type="checkbox" role="switch" checked> Push notifications</label>
<label><input type="checkbox" role="switch"> Weekly digest</label>
<label><input type="checkbox" role="switch" checked data-tone="info"> Auto-categorise</label>
<label><input type="checkbox" role="switch" disabled> Disabled</label>
</div>API
| Name | Type | Description |
|---|---|---|
input[type=checkbox][role=switch] | markup | Switch. |
data-tone / --tone | colour | Colour when on. |