Switch
A setting that takes effect the moment it is pressed. That makes it the wrong control inside a form with a save button, where nothing else has happened yet.
Reach for it
A setting that takes effect the moment it is flipped.
Not for
Something that only applies on submit. That is a Checkbox.
States
The role tells a screen reader this is on or off rather than checked, which is the difference a user needs to hear when there is no save button coming.
Spread across a row
A settings panel lists its toggles with the labels on the left and the controls on the right. The spread layout does that with CSS alone, so the label still follows its control in the DOM. Wrap one in a Field for a hint under the row.
Credit limits are revised when the debtor's grade changes.
A quiet label
A switch at the edge of a screen, such as a preference at the foot of the sidebar, should not compete with the page. The muted tone sets its label smaller and grey.
API reference
Switch
| Prop | Type | Default | Description |
|---|---|---|---|
| label* | string | - | |
| data-testid | string | - | Names the element for a test. Never rendered, never announced. |
| layout | 'inline' | 'spread' | inline | |
| tone | 'default' | 'muted' | default | |
| checked | boolean | - | |
| defaultChecked | boolean | - | |
| onCheckedChange | (checked: boolean) => void | - | |
| isDisabled | boolean | - | |
| isLabelHidden | boolean | - | Hides the label visually while keeping it announced. |