Skip to content
uiify

Switch

Control that turns a single setting on or off.

Browsers
Chrome 123+Firefox 121+Safari 17.5+
Tier
0
Bundle compressed
319 B
Forced layout budget
0 ms
Axe budget
0
SSR compatible
Yes
Published contract
Test harness

Playground

Switch

Default

Disabled

API

Switch

PropTypeDefaultDescription
checkedboolean—Checked state, making the switch controlled.
defaultCheckedboolean—Starting checked state for the uncontrolled switch, which the native checkbox then owns.
onCheckedChange(checked: boolean) => void—Called with the new checked state when the user toggles the switch.
disabledbooleanfalseDisables the native input and sets the data-disabled attribute.
renderReactElement | ((props, state) => ReactElement)—Replace the rendered element while keeping behavior and accessibility wiring.

Keyboard

KeyAction
SpaceToggle when focused

Accessibility

Switch role with aria-checked; keyboard matches native checkbox conventions.

Styling hooks

data-statedata-disabled