Skip to content

Switch

A toggle switch component built on Base UI.

Installation

First install? Complete the one-time host setup.

Live preview

A toggle for an on/off setting like dark mode. Prefer it over a checkbox when the change takes effect right away, not on submit.

Loading preview…

Props

PropTypeDefaultDescription
checkedbooleanControlled on/off state.
defaultCheckedbooleanInitial state when uncontrolled.
onCheckedChange(checked: boolean) => voidFires when the user flips the switch.
disabledbooleanfalseDims the switch and blocks interaction.