Switch

Forms

A toggle switch for binary on/off choices. Use switches for settings that take effect immediately without requiring a form submission.

Import

import { Switch } from "@/components/ui/switch";

Usage

Basic Switch

Standard toggle switch

Controlled Switch

Switch with controlled state

Settings Example

Common settings toggle patterns

Disabled States

Switches in disabled state

API Reference

label
string

Label text displayed next to the switch

checked
boolean

Controlled checked state

defaultCheckedfalse
boolean

Initial checked state (uncontrolled)

disabledfalse
boolean

Whether the switch is disabled

onChange
(e: ChangeEvent) => void

Handler called when state changes