{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "tilt",
  "type": "registry:component",
  "title": "Tilt",
  "description": "A wrapper that tilts its content in 3D toward the pointer on hover and springs back, with an optional glare.",
  "categories": [
    "motion"
  ],
  "dependencies": [
    "motion"
  ],
  "registryDependencies": [
    "@rivier-ui/theme",
    "@rivier-ui/cn",
    "@rivier-ui/motion"
  ],
  "files": [
    {
      "path": "registry/motion/tilt.tsx",
      "type": "registry:component",
      "target": "components/motion/tilt.tsx",
      "content": "\"use client\";\n/**\n * @name tilt\n * @category motion\n * @description A wrapper that tilts its content in 3D toward the pointer on hover and springs back, with an optional glare.\n * @when A featured card, a product shot, a pricing plan worth lifting off the page. One or a few per view; not for forms or anything read at length, and it does nothing on touch screens.\n * @example\n * <Tilt max={8} glare className=\"max-w-sm\">\n *   <Card>\n *     <CardHeader>\n *       <CardTitle>Studio plan</CardTitle>\n *       <CardDescription>Everything, for one team</CardDescription>\n *     </CardHeader>\n *   </Card>\n * </Tilt>\n */\nimport { motion, useSpring } from \"motion/react\";\nimport { useEffect, useImperativeHandle, useRef, type ComponentProps } from \"react\";\nimport { cn } from \"@/lib/cn\";\nimport { SPRING, isFinePointer, useMotionSafe } from \"@/lib/motion\";\n\nexport type TiltProps = ComponentProps<\"div\"> & {\n  /** The largest tilt, in degrees. Default 8. */\n  max?: number;\n  /** The perspective distance, in pixels: smaller is more dramatic. Default 800. */\n  perspective?: number;\n  /** Adds a soft highlight-coloured light across the top that brightens as the card tilts back. Default false. */\n  glare?: boolean;\n  /** Classes for the tilting element that holds the children. */\n  contentClassName?: string;\n};\n\n/**\n * The root sets the perspective, keeps its place and is the hover area; the inner element rotates\n * (rotateX/rotateY, transform only). The glare is a gradient drawn once and never repainted: only its\n * opacity changes. It takes the corner radius of the first child's surface through `rounded-surface`.\n */\nexport function Tilt({ className, contentClassName, max = 8, perspective = 800, glare = false, children, style, ref, ...props }: TiltProps) {\n  const rootRef = useRef<HTMLDivElement>(null);\n  useImperativeHandle(ref, () => rootRef.current as HTMLDivElement, []);\n  const safe = useMotionSafe();\n  const rotateX = useSpring(0, SPRING);\n  const rotateY = useSpring(0, SPRING);\n  const glareOpacity = useSpring(0, SPRING);\n\n  useEffect(() => {\n    const root = rootRef.current;\n    if (!safe || !root || !isFinePointer()) return;\n    const move = (event: PointerEvent): void => {\n      if (event.pointerType === \"touch\") return;\n      const rect = root.getBoundingClientRect();\n      if (rect.width === 0 || rect.height === 0) return;\n      const across = (event.clientX - rect.left) / rect.width - 0.5;\n      const down = (event.clientY - rect.top) / rect.height - 0.5;\n      rotateX.set(-down * 2 * max);\n      rotateY.set(across * 2 * max);\n      glareOpacity.set(Math.max(0, Math.min(1, 0.5 - down)));\n    };\n    const leave = (): void => {\n      rotateX.set(0);\n      rotateY.set(0);\n      glareOpacity.set(0);\n    };\n    root.addEventListener(\"pointermove\", move, { passive: true });\n    root.addEventListener(\"pointerleave\", leave, { passive: true });\n    return () => {\n      root.removeEventListener(\"pointermove\", move);\n      root.removeEventListener(\"pointerleave\", leave);\n      rotateX.jump(0);\n      rotateY.jump(0);\n      glareOpacity.jump(0);\n    };\n  }, [safe, max, rotateX, rotateY, glareOpacity]);\n\n  return (\n    <div ref={rootRef} data-slot=\"tilt\" className={cn(className)} style={{ perspective, ...style }} {...props}>\n      <motion.div data-slot=\"tilt-content\" className={cn(\"relative h-full\", contentClassName)} style={{ rotateX, rotateY }}>\n        {children}\n        {glare ? (\n          <motion.div\n            aria-hidden=\"true\"\n            data-slot=\"tilt-glare\"\n            className=\"pointer-events-none absolute inset-0 rounded-surface\"\n            style={{\n              opacity: glareOpacity,\n              backgroundImage:\n                \"radial-gradient(120% 80% at 50% 0%, color-mix(in oklab, var(--highlight) 28%, transparent), transparent 70%)\",\n            }}\n          />\n        ) : null}\n      </motion.div>\n    </div>\n  );\n}\n"
    }
  ],
  "meta": {
    "category": "motion",
    "when": "A featured card, a product shot, a pricing plan worth lifting off the page. One or a few per view; not for forms or anything read at length, and it does nothing on touch screens.",
    "example": "<Tilt max={8} glare className=\"max-w-sm\">\n  <Card>\n    <CardHeader>\n      <CardTitle>Studio plan</CardTitle>\n      <CardDescription>Everything, for one team</CardDescription>\n    </CardHeader>\n  </Card>\n</Tilt>",
    "client": true
  }
}
