Switch

A binary setting control for immediate on/off preferences. One size: a 50 × 30px track.

Preview#

Controls
import { Switch } from "raft-ui";

<Switch aria-label="Setting" />

States#

Field#

Show alerts when new messages arrive.

API#WIP

checked
boolean
Controlled checked state. Pair with onCheckedChange.
defaultCheckeddefault: false
boolean
Initial checked state for uncontrolled usage.
onCheckedChange
(checked: boolean, details) => void
Called when the switch is toggled.
disableddefault: false
boolean
Disables the switch.
readOnlydefault: false
boolean
Keeps the switch focusable but prevents toggling.
requireddefault: false
boolean
Marks the hidden native input required for form validation.
...props
Base UI Switch.Root.Props
Form props (name, value, uncheckedValue, form) plus Base UI render props.
...props
Base UI Switch.Thumb.Props
Optional thumb slot for custom visuals. Switch renders it by default.