Dinachi

Switch

A binary control that lets users turn an option on or off.

#Installation

npx @dinachi/cli@latest add switch

#Usage

tsx
import { Switch, SwitchThumb } from "@/components/ui/switch"

#Examples

Default Switch

A basic switch toggle

Controlled Switch

Switch with controlled state and status display

Status: Disabled

Switch States

Switches in different states including disabled

#API Reference

PropTypeDefaultDescription
checkedbooleanThe controlled checked state.
defaultCheckedbooleanfalseThe initial checked state when uncontrolled.
onCheckedChange(checked: boolean) => voidCallback fired when checked state changes.
disabledbooleanfalseDisables the switch.
requiredbooleanfalseMarks the switch as required in a form.