{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "magic-card",
  "title": "Magic Card",
  "author": "Ballmac <https://ui.ballmac.com>",
  "description": "A card with a two-color light that follows the pointer along its border, with an optional soft glow inside, driven by CSS variables so moving never re-renders, and a steady light on keyboard focus.",
  "dependencies": [
    "motion@^12"
  ],
  "registryDependencies": [
    "utils"
  ],
  "files": [
    {
      "path": "registry/ballmac/components/magic-card.tsx",
      "content": "// Ballmac UI: Magic Card. https://ui.ballmac.com/components/magic-card\n\"use client\"\n\nimport * as React from \"react\"\nimport { useReducedMotion } from \"motion/react\"\n\nimport { cn } from \"@/lib/utils\"\n\ntype MagicTone = \"chart-1\" | \"chart-2\" | \"chart-3\" | \"chart-4\" | \"chart-5\" | \"primary\"\n\nconst VAR: Record<MagicTone, string> = {\n  \"chart-1\": \"var(--chart-1)\",\n  \"chart-2\": \"var(--chart-2)\",\n  \"chart-3\": \"var(--chart-3)\",\n  \"chart-4\": \"var(--chart-4)\",\n  \"chart-5\": \"var(--chart-5)\",\n  primary: \"var(--primary)\",\n}\n\ntype MagicCardProps = React.ComponentProps<\"div\"> & {\n  /** Radius of the light that follows the pointer, in pixels. */\n  size?: number\n  /** First color of the border light. */\n  from?: MagicTone\n  /** Second color of the border light. */\n  to?: MagicTone\n  /** Also light the inside of the card faintly. */\n  glow?: boolean\n  /** Classes for the inner surface. */\n  contentClassName?: string\n}\n\nfunction MagicCard({ size = 260, from = \"chart-1\", to = \"chart-4\", glow = true, className, contentClassName, children, onPointerMove, onPointerLeave, onFocus, onBlur, ...props }: MagicCardProps) {\n  const reduce = useReducedMotion()\n  const ref = React.useRef<HTMLDivElement>(null)\n\n  // The pointer position goes straight into CSS variables, so moving never re-renders React.\n  const place = React.useCallback((x: number, y: number, on: boolean) => {\n    const el = ref.current\n    if (!el) return\n    el.style.setProperty(\"--mx\", `${x}px`)\n    el.style.setProperty(\"--my\", `${y}px`)\n    el.style.setProperty(\"--m-on\", on ? \"1\" : \"0\")\n  }, [])\n\n  return (\n    <div\n      ref={ref}\n      data-slot=\"magic-card\"\n      onPointerMove={(e) => {\n        onPointerMove?.(e)\n        if (reduce) return\n        const box = e.currentTarget.getBoundingClientRect()\n        place(e.clientX - box.left, e.clientY - box.top, true)\n      }}\n      onPointerLeave={(e) => {\n        onPointerLeave?.(e)\n        place(0, 0, false)\n      }}\n      onFocus={(e) => {\n        onFocus?.(e)\n        const box = e.currentTarget.getBoundingClientRect()\n        place(box.width / 2, box.height / 2, true)\n      }}\n      onBlur={(e) => {\n        onBlur?.(e)\n        place(0, 0, false)\n      }}\n      className={cn(\"group/magic relative isolate rounded-xl p-px [--m-on:0]\", className)}\n      style={\n        {\n          \"--from\": VAR[from],\n          \"--to\": VAR[to],\n          \"--size\": `${size}px`,\n          background:\n            \"radial-gradient(var(--size) circle at var(--mx, -999px) var(--my, -999px), var(--from), var(--to) 45%, transparent 75%), var(--border)\",\n        } as React.CSSProperties\n      }\n      {...props}\n    >\n      <div className={cn(\"relative h-full overflow-hidden rounded-[calc(var(--radius-xl)-1px)] bg-card text-card-foreground\", contentClassName)}>\n        {glow && (\n          <span\n            aria-hidden=\"true\"\n            className=\"pointer-events-none absolute inset-0 opacity-[calc(var(--m-on)*0.5)] transition-opacity duration-300 motion-reduce:transition-none\"\n            style={{ background: \"radial-gradient(var(--size) circle at var(--mx, -999px) var(--my, -999px), color-mix(in oklab, var(--from) 18%, transparent), transparent 70%)\" }}\n          />\n        )}\n        <div className=\"relative\">{children}</div>\n      </div>\n    </div>\n  )\n}\n\nexport { MagicCard, type MagicCardProps, type MagicTone }\n",
      "type": "registry:ui",
      "target": "@components/ballmac/magic-card.tsx"
    }
  ],
  "meta": {
    "schema": 1,
    "tier": "free",
    "tags": [
      "card",
      "hover",
      "gradient",
      "border",
      "pointer"
    ],
    "version": "1.0.0",
    "updated": "2026-10-01",
    "ai": {
      "summary": "<MagicCard from to size glow contentClassName>content</MagicCard>. from and to are chart tokens. Use spotlight-card for a single soft glow and this for a colored border light.",
      "whenToUse": [
        "Feature and pricing cards on dark or light pages",
        "Any card grid that should feel responsive to the pointer"
      ],
      "whenNotToUse": [
        "Dense data UI",
        "Cards that are not interactive"
      ],
      "composesWith": [
        "spotlight-card",
        "tilt-card",
        "bento-grid"
      ],
      "a11y": [
        {
          "keys": "Focus",
          "action": "A centered light shows when anything inside has focus"
        },
        {
          "keys": "Reduced motion",
          "action": "No pointer tracking; a plain border remains"
        }
      ],
      "customization": [
        "from and to tones",
        "size",
        "glow",
        "contentClassName"
      ]
    },
    "examples": [
      "magic-card-demo",
      "magic-card-colors"
    ],
    "url": "https://ui.ballmac.com/components/magic-card"
  },
  "categories": [
    "motion"
  ],
  "type": "registry:ui"
}