Switch

A control that toggles between on and off.

Save changes every few seconds.

Installation

  1. Add the registryOnce per project
  2. Add switch

Usage

Use a switch for settings that apply right away. For a choice that applies when a form is submitted, use a Checkbox.

Examples

With a label

Nest the switch in a FieldLabel so clicking the text toggles it.

Sizes

size="sm" makes a smaller switch. Without visible text, give it an aria-label.

Disabled

Invalid

Set invalid on the Field and explain the problem with a FieldError.

Props

The tables leave out className, style and render. Parts built on Base UI take them as its styling and composition guides describe.

Switch