{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "radio-card-group",
  "type": "registry:component",
  "title": "Radio Card Group",
  "description": "Selectable cards backed by native radios. A highlight slides to the chosen card and the radio dot springs in. Arrow keys move the selection.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "micro",
    "radio",
    "cards",
    "select",
    "plan",
    "form",
    "highlight"
  ],
  "docs": "https://hyperblur.dev/effects/radio-card-group",
  "files": [
    {
      "path": "registry/hyperblur/radio-card-group.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/radio-card-group.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface RadioCardOption {\n  value: string;\n  label: string;\n  description?: string;\n  meta?: string;\n  disabled?: boolean;\n}\n\nexport interface RadioCardGroupProps\n  extends Omit<React.HTMLAttributes<HTMLDivElement>, \"defaultValue\" | \"onChange\"> {\n  options: RadioCardOption[];\n  value?: string;\n  defaultValue?: string;\n  onValueChange?: (value: string) => void;\n  name?: string;\n  columns?: number;\n  accent?: string;\n  disabled?: boolean;\n}\n\nconst css = `\n.hb-qn4 {\n  position: relative;\n  display: grid;\n  grid-template-columns: repeat(var(--hb-qn4-cols), minmax(0, 1fr));\n  gap: 8px;\n  box-sizing: border-box;\n  width: 100%;\n  font: inherit;\n  color: #ededed;\n}\n.hb-qn4 *, .hb-qn4 *::before, .hb-qn4 *::after { box-sizing: border-box; }\n.hb-qn4-hl {\n  position: absolute;\n  top: 0;\n  left: 0;\n  width: 0;\n  height: 0;\n  border: 1px solid var(--hb-qn4-a);\n  border-radius: 14px;\n  background: color-mix(in srgb, var(--hb-qn4-a) 12%, transparent);\n  box-shadow: 0 0 24px -8px var(--hb-qn4-a);\n  opacity: 0;\n  pointer-events: none;\n}\n.hb-qn4-hl[data-ready=\"true\"] {\n  transition: transform 0.38s cubic-bezier(0.3, 1.15, 0.4, 1), width 0.38s cubic-bezier(0.3, 1.15, 0.4, 1), height 0.38s cubic-bezier(0.3, 1.15, 0.4, 1), opacity 0.2s ease;\n}\n.hb-qn4-card {\n  position: relative;\n  z-index: 1;\n  display: grid;\n  grid-template-columns: auto minmax(0, 1fr) auto;\n  align-items: center;\n  gap: 12px;\n  min-width: 0;\n  padding: 9px 14px;\n  border: 1px solid #262626;\n  border-radius: 14px;\n  cursor: pointer;\n  transition: border-color 0.25s ease;\n  -webkit-tap-highlight-color: transparent;\n}\n.hb-qn4-card:hover { border-color: #3d3d3d; }\n.hb-qn4-card[data-checked=\"true\"] { border-color: transparent; }\n.hb-qn4-card[data-disabled=\"true\"] { opacity: 0.45; cursor: not-allowed; }\n.hb-qn4-in {\n  position: absolute;\n  inset: 0;\n  width: 100%;\n  height: 100%;\n  margin: 0;\n  opacity: 0;\n  cursor: inherit;\n}\n.hb-qn4-card:has(.hb-qn4-in:focus-visible) { outline: 2px solid var(--hb-qn4-a); outline-offset: 2px; }\n.hb-qn4-dot {\n  position: relative;\n  width: 20px;\n  height: 20px;\n  border: 1.5px solid #4a4a4a;\n  border-radius: 50%;\n  transition: border-color 0.25s ease, background 0.25s ease;\n}\n.hb-qn4-dot::before {\n  content: \"\";\n  position: absolute;\n  inset: 3px;\n  border-radius: 50%;\n  background: var(--hb-qn4-a);\n  transform: scale(0);\n  transition: transform 0.3s cubic-bezier(0.34, 1.7, 0.64, 1);\n}\n.hb-qn4-dot::after {\n  content: \"\";\n  position: absolute;\n  inset: -1.5px;\n  border: 2px solid var(--hb-qn4-a);\n  border-radius: 50%;\n  opacity: 0;\n  pointer-events: none;\n}\n.hb-qn4-card[data-checked=\"true\"] .hb-qn4-dot { border-color: var(--hb-qn4-a); }\n.hb-qn4-card[data-checked=\"true\"] .hb-qn4-dot::before { transform: scale(1); }\n.hb-qn4-card[data-checked=\"true\"] .hb-qn4-dot::after { animation: hb-qn4-ping 0.55s ease-out; }\n.hb-qn4-body { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }\n.hb-qn4-title { font-size: 14px; font-weight: 600; color: #ededed; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n.hb-qn4-desc { font-size: 12px; color: #8f8f8f; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n.hb-qn4-meta { font-size: 13px; font-weight: 600; color: #a1a1a1; font-variant-numeric: tabular-nums; white-space: nowrap; transition: color 0.25s ease; }\n.hb-qn4-card[data-checked=\"true\"] .hb-qn4-meta { color: #ededed; }\n@keyframes hb-qn4-ping {\n  0% { opacity: 0.6; transform: scale(1); }\n  100% { opacity: 0; transform: scale(1.9); }\n}\n@media (prefers-reduced-motion: reduce) {\n  .hb-qn4-hl[data-ready=\"true\"], .hb-qn4-card, .hb-qn4-dot, .hb-qn4-dot::before, .hb-qn4-meta { transition: none; }\n  .hb-qn4-card[data-checked=\"true\"] .hb-qn4-dot::after { animation: none; }\n}\n`;\n\nexport function RadioCardGroup({\n  options,\n  value,\n  defaultValue,\n  onValueChange,\n  name,\n  columns = 1,\n  accent = \"#2f7bff\",\n  disabled = false,\n  className = \"\",\n  style,\n  ...rest\n}: RadioCardGroupProps) {\n  const autoName = React.useId();\n  const groupName = name ?? autoName;\n  const controlled = value !== undefined;\n  const [inner, setInner] = React.useState<string | undefined>(defaultValue);\n  const current = controlled ? value : inner;\n  const groupRef = React.useRef<HTMLDivElement>(null);\n  const hlRef = React.useRef<HTMLDivElement>(null);\n  const cardRefs = React.useRef<Record<string, HTMLLabelElement | null>>({});\n\n  const measure = React.useCallback(() => {\n    const hl = hlRef.current;\n    if (!hl) return;\n    const card = current !== undefined ? cardRefs.current[current] : null;\n    if (!card) {\n      hl.style.opacity = \"0\";\n      return;\n    }\n    hl.style.width = `${card.offsetWidth}px`;\n    hl.style.height = `${card.offsetHeight}px`;\n    hl.style.transform = `translate(${card.offsetLeft}px, ${card.offsetTop}px)`;\n    hl.style.opacity = \"1\";\n  }, [current]);\n\n  React.useLayoutEffect(() => {\n    measure();\n    const group = groupRef.current;\n    const hl = hlRef.current;\n    if (!group || !hl) return;\n    const frame = requestAnimationFrame(() => {\n      hl.dataset.ready = \"true\";\n    });\n    const observer = new ResizeObserver(measure);\n    observer.observe(group);\n    return () => {\n      cancelAnimationFrame(frame);\n      observer.disconnect();\n    };\n  }, [measure, options.length, columns]);\n\n  function choose(next: string) {\n    if (!controlled) setInner(next);\n    onValueChange?.(next);\n  }\n\n  const vars = {\n    \"--hb-qn4-a\": accent,\n    \"--hb-qn4-cols\": Math.max(1, columns),\n    ...style,\n  } as React.CSSProperties;\n\n  return (\n    <>\n      <style href=\"hb-radio-card-group\" precedence=\"default\">{css}</style>\n      <div\n        ref={groupRef}\n        role=\"radiogroup\"\n        className={`hb-qn4 ${className}`}\n        style={vars}\n        aria-disabled={disabled || undefined}\n        {...rest}\n      >\n        <div ref={hlRef} className=\"hb-qn4-hl\" aria-hidden=\"true\" />\n        {options.map((option) => {\n          const checked = current === option.value;\n          const off = disabled || option.disabled === true;\n          return (\n            <label\n              key={option.value}\n              ref={(el) => {\n                cardRefs.current[option.value] = el;\n              }}\n              className=\"hb-qn4-card\"\n              data-checked={checked}\n              data-disabled={off}\n            >\n              <input\n                type=\"radio\"\n                className=\"hb-qn4-in\"\n                name={groupName}\n                value={option.value}\n                checked={checked}\n                disabled={off}\n                onChange={() => choose(option.value)}\n              />\n              <span className=\"hb-qn4-dot\" aria-hidden=\"true\" />\n              <span className=\"hb-qn4-body\">\n                <span className=\"hb-qn4-title\">{option.label}</span>\n                {option.description ? <span className=\"hb-qn4-desc\">{option.description}</span> : null}\n              </span>\n              {option.meta ? <span className=\"hb-qn4-meta\">{option.meta}</span> : null}\n            </label>\n          );\n        })}\n      </div>\n    </>\n  );\n}\n"
    }
  ]
}