{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "switch-08",
  "title": "Switch with state label",
  "description": "A switch whose On and Off label swaps as it changes.",
  "dependencies": [
    "motion"
  ],
  "registryDependencies": [
    "https://ui.ndekocode.dev/r/label.json",
    "https://ui.ndekocode.dev/r/switch.json",
    "https://ui.ndekocode.dev/r/theme.json",
    "https://ui.ndekocode.dev/r/use-prefers-reduced-motion.json"
  ],
  "files": [
    {
      "path": "registry/ndeko/components/switch/switch-08.tsx",
      "content": "'use client';\n\nimport {\n  AnimatePresence,\n  motion,\n  type Transition,\n  type Variants,\n} from 'motion/react';\nimport { useId, useState } from 'react';\n\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\nimport { Label } from '@/registry/ndeko/ui/label';\nimport { Switch } from '@/registry/ndeko/ui/switch';\n\nconst SWAP_TRANSITION: Transition = { duration: 0.15, ease: [0.2, 0, 0, 1] };\n\nconst LABEL_VARIANTS: Variants = {\n  enter: { opacity: 0, scale: 0.6, filter: 'blur(2px)' },\n  visible: { opacity: 1, scale: 1, filter: 'blur(0px)' },\n  exit: { opacity: 0, scale: 0.6, filter: 'blur(2px)' },\n};\n\nconst FADE_VARIANTS: Variants = {\n  enter: { opacity: 0 },\n  visible: { opacity: 1 },\n  exit: { opacity: 0 },\n};\n\nfunction labelVariantsOf(shouldReduceMotion: boolean | null) {\n  if (shouldReduceMotion) {\n    return FADE_VARIANTS;\n  }\n  return LABEL_VARIANTS;\n}\n\nfunction stateLabelOf(isOn: boolean) {\n  if (isOn) {\n    return 'On';\n  }\n  return 'Off';\n}\n\nexport default function Switch08() {\n  const id = useId();\n  const [isOn, setIsOn] = useState(true);\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const labelVariants = labelVariantsOf(shouldReduceMotion);\n  const stateLabel = stateLabelOf(isOn);\n\n  return (\n    <div className='inline-flex items-center gap-2'>\n      <Switch\n        id={id}\n        checked={isOn}\n        onCheckedChange={setIsOn}\n        aria-label='Auto-save'\n      />\n      <Label htmlFor={id} className='relative'>\n        <AnimatePresence mode='popLayout' initial={false}>\n          <motion.span\n            key={stateLabel}\n            className='flex'\n            variants={labelVariants}\n            initial='enter'\n            animate='visible'\n            exit='exit'\n            transition={SWAP_TRANSITION}\n          >\n            {stateLabel}\n          </motion.span>\n        </AnimatePresence>\n      </Label>\n    </div>\n  );\n}\n",
      "type": "registry:component"
    }
  ],
  "categories": [
    "components",
    "switch"
  ],
  "type": "registry:component"
}