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

PropTypeDefaultDescription
labelstringLabel text displayed next to the switch
checkedbooleanControlled checked state
defaultCheckedbooleanfalseInitial checked state (uncontrolled)
disabledbooleanfalseWhether the switch is disabled
onChange(e: ChangeEvent) => voidHandler called when state changes

Related Components