Skip to content
SevenUI
Sign inGet Pro
On this page

Switch

Displays a switch built on the Base UI Switch primitive, for turning a setting on or off with an accessible label.

Displays a switch built on the UI SDK Switch component, for turning a setting on or off with an accessible label.

Installation

Usage

API reference

The UI SDK flavour is built on UI SDK Switch. Its API is the SevenUI wrapper's, the same in both flavours: export names, props, data-slot values and the render prop, so code that uses only the SevenUI exports compiles against either flavour. What behaves differently, and any prop that is ignored or not supported, is listed below; code that imports a Base UI or third-party library directly needs changes. Switch to Base UI to read the prop tables, which describe that shared API in Base UI's terms.

Differences on UI SDK

  • Enter submits the form; only Space toggles. inputRef is accepted and ignored.

Switch

Extends the Base UI Switch Root — all its props apply: checked/defaultChecked, onCheckedChange, name/value and uncheckedValue for form submission. The thumb is built in.

PropTypeDefault
size"default" | "sm""default"
checked / defaultCheckedbooleanfalse
onCheckedChange(checked: boolean) => void—
disabledbooleanfalse
name / valuestring — form submission—

Was this page helpful?