When to use
Section titled “When to use”Switch is for a setting that applies the moment it changes: turning on notifications, dark mode, enabling a feature.
When not to use
Section titled “When not to use”- For a choice applied when the form is submitted: Use a Checkbox.
- For more than two options: Use a RadioGroup or a Select.
- For a toolbar button: Use a Toggle.
Anatomy
Section titled “Anatomy”Option description goes here.
import { Switch } from '@bigbang/ui';
export default function WithDescription() { return <Switch label="Option label" description="Option description goes here." defaultChecked />;}- Track: 32 × 18 px (
switch-width-md,switch-height-md), fully round;size="sm"gives 24 × 14 px for dense rows. The off track stays a strong grey so it keeps 3:1 against the page. - Thumb: 16 px (
switch-thumb-md, 12 px insm), flat; slides to the end edge when on. - Label:
body-md; part of the click area with the track. - Description: optional; aligned with the label text.
Behaviour
Section titled “Behaviour”- Click and Space toggle the switch;
onCheckedChangeis called at once. - While
loading, the switch keeps focus, reportsaria-busyand ignores changes. - In right-to-left text the thumb slides the other way.
- A hidden
<input>is submitted with the form;namegoes to it.
Guidelines
Section titled “Guidelines”- Write the label as the name of the setting: “Notifications”. Do not add “On” or “Off”; the track shows the state.
- Show
loadingwhen saving can take over a second; on failure, revert the state and say why. - Do not use a switch for choices tied to a form’s submit button.
Content
Section titled “Content”- The label is a short noun phrase; it has no full stop.
- The description says what the setting does.
| Turkish | English |
|---|---|
| Yükleniyor | Loading |
| Kaydediliyor | Saving |