Dinachi

Switch

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

View Source

#Installation

npx @dinachi/cli@latest add switch

#Usage

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

#Examples

#API Reference

PropTypeDefaultDescription
checkedbooleanThe controlled checked state
defaultCheckedbooleanfalseThe initial checked state when uncontrolled
onCheckedChange(checked: boolean, details: object) => voidCallback fired when checked state changes
namestringIdentifies the field when a form is submitted
valuestringValue submitted when switch is on (defaults to 'on')
disabledbooleanfalseDisables the switch
readOnlybooleanfalsePrevents activation and deactivation
requiredbooleanfalseMarks the switch as required in a form