- Docs
- Components
- Forms
Switch
A setting, on or off, applied at once. A setting that waits for Save is a Checkbox.
- Import
- @qeetrix/react
- Status
- StableSince 0.0.2
- Renders
<span role="switch">Server-rendered- Tested
- WCAG 2.2 AAaxe on every pull request
01
Playground
Every prop, live, and the code it takes.
Every Monday at 9 am.
import { Switch } from "@qeetrix/react";
<Switch
label="Email me a weekly summary"
description="Every Monday at 9 am."
defaultChecked
/>02
A setting
On or off, at once: no Save. The thumb moves to the end side in either direction.
Every Monday at 9 am.
<Switch label="Email me a weekly summary" description="Every Monday at 9 am." defaultChecked />03
A list of settings
Each its own row, each applied as it's switched.
<Stack gap="md">
<Switch label="New sign-ins" defaultChecked />
<Switch label="Accepted invites" defaultChecked />
<Switch label="Billing changes" />
</Stack>04
Applied at once
checked and onCheckedChange: save as it changes, and say so.
Asked at the next sign-in.
const [on, setOn] = useState(true);
<Switch
label="Two-step sign-in for everyone"
description="Asked at the next sign-in."
checked={on}
onCheckedChange={(next) => { setOn(next); savePolicy({ mfa: next }); }}
/>05
Disabled
Say why in the description.
Needs a verified domain.
<Switch label="Single sign-on only" description="Needs a verified domain." disabled />