Switch

A binary setting control for immediate on/off preferences.

Preview#

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

<Switch aria-label="Setting" />

Sizes#

States#

Field#

Show alerts when new messages arrive.

API#WIP

PropTypeDefaultDescription
size"sm" | "md""sm"Visual size of the switch. Use sm in dense menus and md in form rows.
checkedbooleanControlled checked state. Pair with onCheckedChange.
defaultCheckedbooleanfalseInitial checked state for uncontrolled usage.
onCheckedChange(checked: boolean, details) => voidCalled when the switch is toggled.
disabledbooleanfalseDisables the switch.
readOnlybooleanfalseKeeps the switch focusable but prevents toggling.
requiredbooleanfalseMarks the hidden native input required for form validation.
...propsBase UI Switch.Root.PropsForm props (name, value, uncheckedValue, form) plus Base UI render props.
PropTypeDefaultDescription
...propsBase UI Switch.Thumb.PropsOptional thumb slot for custom visuals. Switch renders it by default.