SYS:ONLINE● ACTIVE
THEME
GITHUBv0.1.0

SWITCH

Binary toggle built on Radix UI. Displays [OFF] / [ON] text labels instead of a sliding thumb. Green glow on checked state.

DEPS:@radix-ui/react-switch

PREVIEW

INSTALLATION

BASH
npx shadcn@latest add @scificn/switch

USAGE

TSX
import { Switch } from '@/ui/switch'

export function Example() {
  return (
    <Switch
      label="AUTO-PILOT"
      onCheckedChange={(checked) => console.log('auto-pilot:', checked)}
    />
  )
}

STATES

OFF
ON
DISABLED OFF
DISABLED ON

CONTROLLED

TSX
import { useState } from 'react'
import { Switch } from '@/ui/switch'

export function Controlled() {
  const [enabled, setEnabled] = useState(false)
  return (
    <Switch
      label="WARP DRIVE"
      checked={enabled}
      onCheckedChange={setEnabled}
    />
  )
}

PROPS

PROPTYPEDEFAULTDESCRIPTION
labelstringOptional text label next to the switch. Auto-generates the id/htmlFor binding.
checkedbooleanControlled checked state.
defaultCheckedbooleanfalseInitial state (uncontrolled).
onCheckedChange(checked: boolean) => voidCallback fired on state change.
disabledbooleanfalseDisables the switch and reduces opacity.