Switch()
Switch(
__namedParameters):Element
Switch - A toggle control for binary state changes
Provides an accessible toggle switch component for enabling/disabling features or settings. Offers clear visual feedback for on/off states with smooth transitions and proper keyboard and screen reader support.
Parameters
__namedParameters
Returns
Element
Examples
// Basic switch
<Switch>Enable notifications</Switch>
// Controlled switch
<Switch
isSelected={isEnabled}
onChange={setIsEnabled}
>
Dark mode
</Switch>
// Switch with default state
<Switch defaultSelected>
Auto-save documents
</Switch>
// Disabled switch
<Switch isDisabled>
Premium feature (upgrade required)
</Switch>
// Switch without label (icon-only)
<Switch aria-label="Toggle sidebar" />