Component

Switch

A toggle switch with accessible keyboard and ARIA support. Three sizes and disabled state. Uses the headless @refraction-ui/switch core.

Sizes

Three sizes: small, default, and large.

Small
Default
Large

Installation

$pnpm add @refraction-ui/react-switch

Usage

tsx
import { Switch } from '@refraction-ui/react-switch'

export function MyComponent() {
  const [enabled, setEnabled] = useState(false)
  return <Switch checked={enabled} onCheckedChange={setEnabled} />
}

States

On/off and disabled states.

Off
On
Disabled Off
Disabled On

Props

PropTypeDefaultDescription
checkedbooleanfalseWhether the switch is on.
onCheckedChange(checked: boolean) => void--Callback when toggled.
disabledbooleanfalseDisables the switch.
size'sm' | 'default' | 'lg''default'Size of the switch.
classNamestring--Additional CSS classes.