A switch component with label support. The label can be placed at the Start, End, Top, or Bottom position with full RTL support.
Loading demo: switch-real-world
npx sdaia-ui@latest add switch
import { Switch } from '@/components/ui/Switch';<Switch placement="start" />The default unchecked state.
Loading demo: switch-label-off
Use `on={true}` or `defaultChecked` to set the switch to the on state.
Loading demo: switch-label-on
Use `state="Disabled" to show the disabled state.
Loading demo: switch-label-disabled
Props for the Switch component.
Prop | Type | Default | Required |
|---|---|---|---|
label | ReactNode | — | optional |
placement | "start" | "end" | "top" | "bottom" | "start" | optional |
checked | boolean | — | optional |
defaultChecked | boolean | — | optional |
size | "md" | "lg" | "md" | optional |
error | string | — | optional |
helperText | string | — | optional |
disabled | boolean | false | optional |
onCheckedChange | (checked: boolean) => void | — | optional |
onChange | ChangeEventHandler<HTMLInputElement> | — | optional |
dir | "ltr" | "rtl" | — | optional |
How this component behaves at the three system breakpoints. Spacing and type tokens switch automatically at 768px and 1280px.
| Screen | Behavior |
|---|---|
| Desktop (1280px and up) | The switch has a fixed size (36 × 20px or 44 × 24px). The label fills the remaining width and wraps. |
| Tablet (768–1279px) | Same layout as desktop, with the tablet token values. |
| Phone (under 768px) | Same switch sizes; label text follows the mobile token values and wraps onto more lines. |