pro-ui

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

PropTypeDefaultDescription
isSelectedbooleanControlled state
defaultSelectedbooleanUncontrolled default
onChange(selected: boolean) => voidCalled on change
isDisabledbooleanDisable the switch
childrenReactNodeLabel

On this page