Search documentation

Find a component or a docs page

Switch

A control that allows the user to toggle between checked and not checked.

Usage

Example

A native checkbox with role="switch": Tab focuses it, Space toggles it, and a label with for= names it.

Checked

Size

size: :sm renders a smaller switch.

Disabled

Aria disabled

Invalid

With flag include_hidden false

By default a hidden input with the same name sends unchecked_value ("0") when the switch is off, like Rails' check_box. include_hidden: false skips it.

Installation

Components

ComponentBuilt usingSource
SwitchPhlex
SwitchDocsPhlex