{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "radio-20",
  "title": "Billing period toggle",
  "description": "Monthly or yearly, with an indicator that slides to the choice.",
  "dependencies": [
    "motion"
  ],
  "registryDependencies": [
    "https://ui.ndekocode.dev/r/radio-group.json",
    "https://ui.ndekocode.dev/r/theme.json",
    "https://ui.ndekocode.dev/r/use-prefers-reduced-motion.json"
  ],
  "files": [
    {
      "path": "registry/ndeko/components/radio/radio-20.tsx",
      "content": "'use client';\n\nimport { motion, type Transition } from 'motion/react';\nimport { useId, useState } from 'react';\n\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\nimport { RadioGroup, RadioGroupItem } from '@/registry/ndeko/ui/radio-group';\n\ntype BillingPeriod = {\n  value: string;\n  label: string;\n  saving?: string;\n};\n\nconst BILLING_PERIODS: BillingPeriod[] = [\n  { value: 'monthly', label: 'Monthly' },\n  { value: 'yearly', label: 'Yearly', saving: '-20%' },\n];\n\nconst INDICATOR_TRANSITION: Transition = {\n  duration: 0.2,\n  ease: [0.2, 0, 0, 1],\n};\n\nconst INSTANT_TRANSITION: Transition = { duration: 0 };\n\nconst INDICATOR = [\n  'absolute inset-0 -z-10 rounded-md bg-card shadow-[0_1px_2px_rgb(0_0_0/0.08)] hairline-ring ring-foreground/10',\n  'dark:bg-foreground/[0.09] dark:ring-foreground/15',\n].join(' ');\n\nconst PERIOD_OPTION = [\n  'relative inline-flex h-7 cursor-pointer select-none items-center justify-center gap-1.5 whitespace-nowrap rounded-md px-3 text-[13px] font-medium text-muted-foreground transition-colors duration-150',\n  'hover:text-foreground has-data-checked:text-foreground has-focus-visible:ring-[3px] has-focus-visible:ring-ring/25',\n].join(' ');\n\nfunction indicatorTransitionOf(shouldReduceMotion: boolean | null) {\n  if (shouldReduceMotion) {\n    return INSTANT_TRANSITION;\n  }\n  return INDICATOR_TRANSITION;\n}\n\nfunction savingToneOf(isSelected: boolean) {\n  if (isSelected) {\n    return 'text-success-foreground transition-colors duration-150';\n  }\n  return 'text-muted-foreground transition-colors duration-150';\n}\n\nexport default function Radio20() {\n  const indicatorId = useId();\n  const [period, setPeriod] = useState('yearly');\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const indicatorTransition = indicatorTransitionOf(shouldReduceMotion);\n\n  return (\n    <RadioGroup\n      value={period}\n      onValueChange={setPeriod}\n      aria-label='Billing period'\n      className='bg-foreground/[0.05] isolate inline-flex gap-0.5 rounded-lg p-0.5'\n    >\n      {BILLING_PERIODS.map((option) => {\n        const isSelected = option.value === period;\n        const savingTone = savingToneOf(isSelected);\n\n        return (\n          <label key={option.value} className={PERIOD_OPTION}>\n            <RadioGroupItem value={option.value} className='sr-only' />\n            {isSelected && (\n              <motion.span\n                layoutId={indicatorId}\n                className={INDICATOR}\n                transition={indicatorTransition}\n              />\n            )}\n            {option.label}\n            {option.saving && (\n              <span className={savingTone}>{option.saving}</span>\n            )}\n          </label>\n        );\n      })}\n    </RadioGroup>\n  );\n}\n",
      "type": "registry:component"
    }
  ],
  "categories": [
    "components",
    "radio"
  ],
  "type": "registry:component"
}