{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "card-radio",
  "type": "registry:ui",
  "title": "Card Radio",
  "description": "A Card Radio component for displaying a radio button with a card.",
  "files": [
    {
      "path": "src/registry/ui/card-radio.tsx",
      "type": "registry:ui",
      "content": "\"use client\";\n\nimport { createContext, useContext, useState } from \"react\";\nimport * as RadioGroupPrimitive from \"@radix-ui/react-radio-group\";\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\nimport { Check } from \"lucide-react\";\nimport { cn } from \"@/lib/utils\";\n\nconst EASE_OUT = [0.23, 1, 0.32, 1] as const;\n\nconst SelectedValueContext = createContext<string | undefined>(undefined);\n\nexport type CardRadioGroupProps = React.ComponentProps<typeof RadioGroupPrimitive.Root>;\n\nexport function CardRadioGroup({\n  value,\n  defaultValue,\n  onValueChange,\n  className,\n  ...props\n}: CardRadioGroupProps) {\n  // Mirrors the selection so items can animate their check badge in and out.\n  const [uncontrolledValue, setUncontrolledValue] = useState(defaultValue);\n  const selected = value ?? uncontrolledValue;\n\n  return (\n    <SelectedValueContext.Provider value={selected}>\n      <RadioGroupPrimitive.Root\n        data-slot=\"card-radio-group\"\n        value={selected}\n        onValueChange={(next) => {\n          if (value === undefined) setUncontrolledValue(next);\n          onValueChange?.(next);\n        }}\n        className={cn(\n          \"grid gap-3 sm:aria-[orientation=horizontal]:auto-cols-fr sm:aria-[orientation=horizontal]:grid-flow-col\",\n          className\n        )}\n        {...props}\n      />\n    </SelectedValueContext.Provider>\n  );\n}\n\nexport type CardRadioItemProps = Omit<\n  React.ComponentProps<typeof RadioGroupPrimitive.Item>,\n  \"title\" | \"children\"\n> & {\n  title: React.ReactNode;\n  description?: React.ReactNode;\n  /** Trailing content such as a price. */\n  aside?: React.ReactNode;\n};\n\nexport function CardRadioItem({\n  value,\n  title,\n  description,\n  aside,\n  className,\n  ...props\n}: CardRadioItemProps) {\n  const isChecked = useContext(SelectedValueContext) === value;\n  const reduceMotion = useReducedMotion();\n\n  return (\n    <RadioGroupPrimitive.Item\n      data-slot=\"card-radio-item\"\n      value={value}\n      className={cn(\n        \"relative flex h-full w-full cursor-pointer flex-col gap-1 rounded-xl border bg-card p-4 pr-10 text-left text-card-foreground outline-none\",\n        \"transition-colors hover:bg-muted/50 data-[state=checked]:border-primary data-[state=checked]:bg-primary/5\",\n        \"focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background\",\n        \"disabled:cursor-not-allowed disabled:opacity-50\",\n        className\n      )}\n      {...props}\n    >\n      <span className=\"font-medium\">{title}</span>\n      {description && <span className=\"text-sm text-muted-foreground\">{description}</span>}\n      {aside && <span className=\"mt-auto pt-2 text-lg font-semibold\">{aside}</span>}\n      <AnimatePresence initial={false}>\n        {isChecked && (\n          <motion.span\n            key=\"check\"\n            aria-hidden\n            className=\"absolute top-3 right-3 flex size-5 items-center justify-center rounded-full bg-primary text-primary-foreground\"\n            initial={reduceMotion ? { opacity: 0 } : { scale: 0.9, opacity: 0 }}\n            animate={{ scale: 1, opacity: 1 }}\n            exit={reduceMotion ? { opacity: 0 } : { scale: 0.9, opacity: 0 }}\n            transition={{ duration: 0.15, ease: EASE_OUT }}\n          >\n            <Check className=\"size-3\" strokeWidth={3} />\n          </motion.span>\n        )}\n      </AnimatePresence>\n    </RadioGroupPrimitive.Item>\n  );\n}\n"
    }
  ],
  "dependencies": [
    "@radix-ui/react-radio-group",
    "lucide-react",
    "motion"
  ]
}
