Switch

A native checkbox with the switch role.

Installation

Examples

Default

It takes a checkbox's props, such as checked and onChange, and assistive technology reads it as on or off. Wrap it and its text in a label.

demo.tsx

Disabled

disabled dims it, on or off.

disabled.tsx

At the end of a row

A settings list sets the switch after its text, with justify-between.

settings.tsx

Anatomy

Each part's data-slot, which a theme styles, is beside it.