Switch

Stable

Toggle switches for binary on/off settings with smooth animations.

Import

import { Switch } from '@brutal-ui/react';

Basic Usage

const [enabled, setEnabled] = useState(true);

<Switch
  checked={enabled}
  onChange={(e) => setEnabled(e.target.checked)}
  label={`Notifications (${enabled ? 'ON' : 'OFF'})`}
/>

Without Label

<Switch checked={true} onChange={() => {}} />

Multiple Switches

Disabled State

Props

PropTypeDefaultDescription
checkedbooleanfalseControlled checked state
onChangefunction-Change event handler
labelstring-Label text
disabledbooleanfalseDisable switch