{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "radio-button",
  "title": "Radio Button",
  "description": "An accessible, animated radio group with a springy dot, a ripple on select, focus ring, optional descriptions and a selectable card variant.",
  "dependencies": [
    "motion",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/radio-button/radio-button.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { motion, AnimatePresence } from \"motion/react\";\nimport { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nfunction cn(...inputs: ClassValue[]) {\n  return twMerge(clsx(inputs));\n}\n\nexport interface RadioButtonOption {\n  value: string;\n  label: string;\n  description?: string;\n  disabled?: boolean;\n}\n\nexport interface RadioButtonProps {\n  options?: RadioButtonOption[];\n  value?: string;\n  defaultValue?: string;\n  onValueChange?: (value: string) => void;\n  name?: string;\n  label?: string;\n  direction?: \"vertical\" | \"horizontal\";\n  variant?: \"default\" | \"card\";\n  disabled?: boolean;\n  size?: number;\n  borderWidth?: number;\n  borderColor?: string;\n  accentColor?: string;\n  dotColor?: string;\n  labelColor?: string;\n  helperColor?: string;\n  ringColor?: string;\n  ringWidth?: number;\n  cardRadius?: number;\n  duration?: number;\n  className?: string;\n}\n\nconst DEFAULT_OPTIONS: RadioButtonOption[] = [\n  { value: \"starter\", label: \"Starter\", description: \"For side projects and quick experiments\" },\n  { value: \"pro\", label: \"Pro\", description: \"For teams shipping every week\" },\n  { value: \"scale\", label: \"Scale\", description: \"Unlimited seats and priority support\" },\n];\n\ninterface RadioVisualProps {\n  isChecked: boolean;\n  disabled: boolean;\n  ring: boolean;\n  size: number;\n  borderWidth: number;\n  borderColor: string;\n  accentColor: string;\n  dotColor: string;\n  ringColor: string;\n  ringWidth: number;\n  duration: number;\n}\n\nfunction RadioVisual({ isChecked, disabled, ring, size, borderWidth, borderColor, accentColor, dotColor, ringColor, ringWidth, duration }: RadioVisualProps) {\n  return (\n    <motion.div\n      className=\"pointer-events-none absolute inset-0 box-border flex items-center justify-center rounded-full\"\n      style={{\n        borderWidth,\n        borderStyle: \"solid\",\n        borderColor: isChecked ? accentColor : borderColor,\n        backgroundColor: isChecked ? accentColor : \"transparent\",\n        boxShadow: ring ? `0 0 0 ${ringWidth}px ${ringColor}` : \"0 0 0 0 transparent\",\n        opacity: disabled ? 0.45 : 1,\n        transition: `border-color ${duration}s ease, background-color ${duration}s ease, box-shadow ${duration}s ease`,\n      }}\n      initial={false}\n      whileTap={disabled ? undefined : { scale: 0.9 }}\n    >\n      <AnimatePresence>\n        {isChecked && (\n          <motion.span\n            key=\"ripple\"\n            className=\"absolute inset-0 rounded-full\"\n            style={{ border: `${borderWidth}px solid ${accentColor}` }}\n            initial={{ scale: 1, opacity: 0.55 }}\n            animate={{ scale: 1.9, opacity: 0 }}\n            exit={{ opacity: 0 }}\n            transition={{ duration: 0.55, ease: \"easeOut\" }}\n          />\n        )}\n      </AnimatePresence>\n      <motion.span\n        className=\"block rounded-full\"\n        style={{ width: size * 0.4, height: size * 0.4, backgroundColor: dotColor }}\n        initial={false}\n        animate={{ scale: isChecked ? 1 : 0, opacity: isChecked ? 1 : 0 }}\n        transition={{ type: \"spring\", stiffness: 520, damping: 22 }}\n      />\n    </motion.div>\n  );\n}\n\nexport function RadioButton({\n  options = DEFAULT_OPTIONS,\n  value,\n  defaultValue,\n  onValueChange,\n  name,\n  label,\n  direction = \"vertical\",\n  variant = \"default\",\n  disabled = false,\n  size = 20,\n  borderWidth = 1.5,\n  borderColor = \"color-mix(in srgb, currentColor 32%, transparent)\",\n  accentColor = \"#F2A841\",\n  dotColor = \"#0A0A0A\",\n  labelColor = \"currentColor\",\n  helperColor = \"color-mix(in srgb, currentColor 55%, transparent)\",\n  ringColor = \"color-mix(in srgb, #F2A841 30%, transparent)\",\n  ringWidth = 3,\n  cardRadius = 16,\n  duration = 0.2,\n  className,\n}: RadioButtonProps) {\n  const autoName = React.useId();\n  const groupName = name ?? autoName;\n  const [internalValue, setInternalValue] = React.useState<string | undefined>(defaultValue ?? options[0]?.value);\n  const [focusedValue, setFocusedValue] = React.useState<string | null>(null);\n  const isControlled = value !== undefined;\n  const current = isControlled ? value : internalValue;\n  const labelSize = size * 0.72;\n  const helperSize = size * 0.62;\n  const isCard = variant === \"card\";\n\n  const select = (next: string) => {\n    if (disabled) return;\n    if (!isControlled) setInternalValue(next);\n    onValueChange?.(next);\n  };\n\n  return (\n    <div role=\"radiogroup\" aria-label={label} aria-disabled={disabled} className={cn(\"inline-flex flex-col gap-3\", className)} style={{ fontFamily: \"Inter, sans-serif\", color: labelColor }}>\n      {label && (\n        <div className=\"font-semibold tracking-[-0.01em]\" style={{ fontSize: labelSize, color: labelColor }}>\n          {label}\n        </div>\n      )}\n      <div className={cn(\"flex\", direction === \"horizontal\" ? \"flex-row flex-wrap\" : \"flex-col\")} style={{ gap: isCard ? 10 : size * 0.7 }}>\n        {options.map((opt) => {\n          const isChecked = current === opt.value;\n          const isDisabled = disabled || opt.disabled;\n          return (\n            <label\n              key={opt.value}\n              className={cn(\"relative flex select-none items-start\", isDisabled ? \"cursor-default\" : \"cursor-pointer\", isCard && \"min-w-[220px]\")}\n              style={{\n                gap: size * 0.55,\n                padding: isCard ? size * 0.7 : 0,\n                borderRadius: cardRadius,\n                border: isCard ? `1px solid ${isChecked ? accentColor : \"color-mix(in srgb, currentColor 14%, transparent)\"}` : undefined,\n                backgroundColor: isCard && isChecked ? `color-mix(in srgb, ${accentColor} 8%, transparent)` : undefined,\n                opacity: opt.disabled && !disabled ? 0.5 : 1,\n                transition: `border-color ${duration}s ease, background-color ${duration}s ease`,\n              }}\n            >\n              <div className=\"relative shrink-0\" style={{ width: size, height: size }}>\n                <input\n                  type=\"radio\"\n                  name={groupName}\n                  value={opt.value}\n                  checked={isChecked}\n                  disabled={isDisabled}\n                  onChange={() => select(opt.value)}\n                  onFocus={(e) => setFocusedValue(e.currentTarget.matches(\":focus-visible\") ? opt.value : null)}\n                  onBlur={() => setFocusedValue(null)}\n                  className=\"absolute inset-0 m-0 h-full w-full opacity-0\"\n                  style={{ cursor: isDisabled ? \"default\" : \"pointer\" }}\n                />\n                <RadioVisual\n                  isChecked={isChecked}\n                  disabled={Boolean(isDisabled)}\n                  ring={focusedValue === opt.value}\n                  size={size}\n                  borderWidth={borderWidth}\n                  borderColor={borderColor}\n                  accentColor={accentColor}\n                  dotColor={dotColor}\n                  ringColor={ringColor}\n                  ringWidth={ringWidth}\n                  duration={duration}\n                />\n              </div>\n              <div className=\"flex flex-col gap-1\" style={{ paddingTop: Math.max(0, (size - labelSize * 1.3) / 2) }}>\n                <span className=\"leading-[1.3] font-semibold tracking-[-0.01em]\" style={{ color: labelColor, fontSize: labelSize }}>\n                  {opt.label}\n                </span>\n                {opt.description && (\n                  <span className=\"leading-[1.4]\" style={{ color: helperColor, fontSize: helperSize }}>\n                    {opt.description}\n                  </span>\n                )}\n              </div>\n            </label>\n          );\n        })}\n      </div>\n    </div>\n  );\n}\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}