Skip to content
GitHub

Switch

A switch for toggling a binary state.

Installation

Usage

Controlled

Use the checked and onCheckedChange props to control the switch state programmatically.

State

Invalid

Use the invalid prop on the <Field /> or in the <Switch /> component to mark the switch as invalid.

Examples

Disabled

Use the disabled prop to disable the switch.

With Description

Use <FieldDescription /> to add a description to the switch.

Focus is shared across devices, and turns off when you leave the app.

Card Style

Use a card-style layout with the switch for a more prominent display.

Form Integration

Integrate the switch into a form with proper validation and error handling.

Terms and conditions
Please read the terms and conditions carefully.

Customizing Size

The switch size is controlled by the [--size-*] CSS variable.

API Reference

Switch

Toggle switch for on/off state. Use with a form control.


For a complete list of props, see the Ark UI documentation.