Components / UI components / Forms
FormsExperimental alpha

Switch

A labelled on/off setting with native focus and switch semantics.

Switch preview

Loading example…

Interactions use local sample data.

Usage and props

Use for an on/off setting, such as email notifications. Give it a label through Field or a native label, and keep the label the same in both states. Use a persistent setting label. The checked value comes from application state, not from an inferred network result.

checkedboolean (optional)
The controlled on/off state.
onCheckedChange(checked: boolean) => void (optional)
Receives the next state. Your application decides when to save the setting.
namestring (optional)
The form-data key. The switch uses a native checkbox input.
disabledboolean (optional)
Prevents changes and excludes the switch from native form submission.
How state and callbacks work

These are the main props for the example. The package's TypeScript declarations include the full API.

Customize and use with a keyboard