Switch
Toggle switch for boolean settings. Built on React Aria.
Import
import { Switch } from '@dangbt/pro-ui'
Usage
<Switch>Email notifications</Switch>
<Switch defaultSelected>Dark mode</Switch>
Controlled
const [on, setOn] = useState(false)
<Switch isSelected={on} onChange={setOn}>
Enable feature flags
</Switch>
Props
| Prop | Type | Default | Description |
|---|---|---|---|
isSelected | boolean | — | Controlled state |
defaultSelected | boolean | — | Uncontrolled default |
onChange | (selected: boolean) => void | — | Called on change |
isDisabled | boolean | — | Disable the switch |
children | ReactNode | — | Label |