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
isSelectedboolean—Controlled state
defaultSelectedboolean—Uncontrolled default
onChange(selected: boolean) => void—Called on change
isDisabledboolean—Disable the switch
childrenReactNode—Label

On this page