{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"tilt-card","type":"registry:ui","title":"Tilt Card","description":"A card that tilts in 3D toward the pointer on a spring, with a glare that tracks the cursor and layers that float at different depths.","author":"GetUrUI <hello@geturui.dev>","dependencies":["motion"],"registryDependencies":[],"files":[{"path":"registry/geturui/ui/tilt-card.tsx","type":"registry:ui","target":"components/ui/tilt-card.tsx","content":"\"use client\";\n\nimport * as React from \"react\";\nimport { motion, useMotionTemplate, useMotionValue, useReducedMotion, useSpring, useTransform } from \"motion/react\";\nimport { cn } from \"@/lib/utils\";\n\nexport interface TiltCardProps extends Omit<React.HTMLAttributes<HTMLDivElement>, \"onDrag\" | \"onDragStart\" | \"onDragEnd\" | \"onAnimationStart\"> {\n  /** Maximum rotation on each axis, degrees. */\n  maxTilt?: number;\n  /** Scale while the pointer is over the card. */\n  scale?: number;\n  /** CSS perspective distance, px. Lower is more dramatic. */\n  perspective?: number;\n  /** Cursor-tracked glare highlight. */\n  glare?: boolean;\n  /** Peak opacity of the glare, 0–1. */\n  glareOpacity?: number;\n  /** Classes for the inner card surface. Avoid overflow-hidden there if you use TiltCardLayer (it flattens 3D). */\n  cardClassName?: string;\n}\n\nconst SPRING = { stiffness: 260, damping: 22, mass: 0.6 };\n\n/** Card that tilts in 3D toward the pointer on a spring, with a glare that follows the cursor. Springs flat on leave. */\nexport function TiltCard({\n  maxTilt = 12,\n  scale = 1.02,\n  perspective = 900,\n  glare = true,\n  glareOpacity = 0.16,\n  className,\n  cardClassName,\n  children,\n  style,\n  onPointerMove,\n  onPointerLeave,\n  onPointerEnter,\n  ...props\n}: TiltCardProps) {\n  const reduce = useReducedMotion();\n  const px = useMotionValue(0.5);\n  const py = useMotionValue(0.5);\n  const hover = useMotionValue(0);\n\n  const rotateX = useSpring(useTransform(py, [0, 1], [maxTilt, -maxTilt]), SPRING);\n  const rotateY = useSpring(useTransform(px, [0, 1], [-maxTilt, maxTilt]), SPRING);\n  const s = useSpring(useTransform(hover, [0, 1], [1, scale]), SPRING);\n  const glareAlpha = useSpring(useTransform(hover, [0, 1], [0, glareOpacity]), { stiffness: 200, damping: 30 });\n  const gx = useTransform(px, (v) => `${v * 100}%`);\n  const gy = useTransform(py, (v) => `${v * 100}%`);\n  const background = useMotionTemplate`radial-gradient(circle at ${gx} ${gy}, rgb(255 255 255 / ${glareAlpha}), transparent 60%)`;\n  const shadowX = useTransform(rotateY, (v) => -v * 1.2);\n  const shadowY = useTransform(rotateX, (v) => v * 1.2 + 18);\n  const boxShadow = useMotionTemplate`${shadowX}px ${shadowY}px 48px -18px var(--scrim)`;\n\n  function track(e: React.PointerEvent<HTMLDivElement>) {\n    const r = e.currentTarget.getBoundingClientRect();\n    px.set(Math.min(1, Math.max(0, (e.clientX - r.left) / r.width)));\n    py.set(Math.min(1, Math.max(0, (e.clientY - r.top) / r.height)));\n  }\n\n  return (\n    <div\n      className={cn(\"relative\", className)}\n      style={{ perspective, ...style }}\n      onPointerEnter={(e) => {\n        onPointerEnter?.(e);\n        if (reduce) return;\n        hover.set(1);\n        track(e);\n      }}\n      onPointerMove={(e) => {\n        onPointerMove?.(e);\n        if (!reduce) track(e);\n      }}\n      onPointerLeave={(e) => {\n        onPointerLeave?.(e);\n        hover.set(0);\n        px.set(0.5);\n        py.set(0.5);\n      }}\n      {...props}\n    >\n      <motion.div\n        style={reduce ? undefined : { rotateX, rotateY, scale: s, boxShadow, transformStyle: \"preserve-3d\" }}\n        className={cn(\n          \"relative h-full rounded-[20px] border border-border bg-surface-raised text-ink will-change-transform\",\n          cardClassName,\n        )}\n      >\n        {children}\n        {glare && !reduce && (\n          <motion.span\n            aria-hidden\n            style={{ background }}\n            className=\"pointer-events-none absolute inset-0 z-10 rounded-[inherit]\"\n          />\n        )}\n      </motion.div>\n    </div>\n  );\n}\n\nexport interface TiltCardLayerProps extends React.HTMLAttributes<HTMLDivElement> {\n  /** How far the layer floats above the card, px (translateZ). */\n  depth?: number;\n}\n\n/** A child layer that floats above the card for parallax. Use inside TiltCard. */\nexport function TiltCardLayer({ depth = 30, className, style, ...props }: TiltCardLayerProps) {\n  return <div className={cn(\"relative\", className)} style={{ transform: `translateZ(${depth}px)`, transformStyle: \"preserve-3d\", ...style }} {...props} />;\n}\n"},{"path":"LICENSE-geturui.md","type":"registry:file","target":"LICENSE-geturui.md","content":"MIT License\n\nCopyright (c) 2026 geturui.com\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n"}],"categories":["components","card","3d","tilt","parallax","glare","hover","springs"],"meta":{"tier":"free","license":"MIT","docs":"https://geturui.com/docs/tilt-card"}}