Harbour UI

Toggle

Controlled boolean switch. Uses role="switch" for correct ARIA semantics and animates smoothly between states.

Preview

Usage

jsx
import { Toggle } from '@/components/ui'
import { useState } from 'react'

function Example() {
  const [enabled, setEnabled] = useState(false)

  return (
    <Toggle
      class="text-sky-300">checked={enabled}
      class="text-sky-300">onChange={setEnabled}
      class="text-sky-300">label="Enable notifications"
    />
  )
}

Props

PropTypeDefaultDescription
checked*booleanControlled state of the toggle.
onChange*(value: boolean) => voidCalled with the new boolean value.
labelstringVisible label next to the switch.
disabledbooleanfalsePrevents interaction.
size'sm' | 'md''md'Controls switch dimensions.