Components
Switch
Renders a toggle switch for boolean on/off states.
Usage
Best practices
Use
Switchfor an instantly-applied on/off setting; useCheckboxfor opt-ins confirmed by a submit, andRadioGroupfor mutually-exclusive choices.Controlled use needs
checked+onCheckedChange; with onlycheckedthe switch won't move - usedefaultCheckedfor uncontrolled.Switchhas no built-in label - associate aLabelviahtmlFor/idso the toggle has an accessible name.