Components
Switch
On/off toggle for a setting that takes effect immediately, in a single 32 × 18px size.
import { Field, Switch } from "@openperf/deft";
<Field.Root>
<Field.Label>
<Switch.Root checked={enabled} onCheckedChange={setEnabled} />
Weekly digest
</Field.Label>
</Field.Root>;When to use
| Need | Component |
|---|---|
| Setting that applies as soon as it changes, no save button | Switch |
| Selecting items in a list or rows in a table | Checkbox |
| Choice between more than two options | Select |
Label
The switch has no label of its own. Inside a Field.Label from Field, a click on the text toggles it. In a settings list, List.Field from List supplies the label: pass the same value as id on the switch and htmlFor on the field. With no visible text, set aria-label.
API
Switch.Root declares no props of its own. The Base UI Switch.Root props used most are checked, defaultChecked, onCheckedChange, disabled, readOnly, required, name and value.