{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"extruded-type-tilt","type":"registry:component","title":"Extruded Type Tilt","description":"Display type with a solid extrusion that swings around as the pointer moves.","dependencies":[],"registryDependencies":[],"files":[{"path":"components/viberdy/extruded-type-tilt.tsx","content":"\"use client\";\n\nimport { useRef, useState } from \"react\";\n\nexport function ExtrudedTypeTilt({\n  text,\n  layers = 10,\n  depth = 2.2,\n  accentFace = true,\n}: {\n  text: string;\n  layers?: number;\n  depth?: number;\n  /** Bright front face. Off, the face sits closer to the extrusion tone. */\n  accentFace?: boolean;\n}) {\n  const boxRef = useRef<HTMLDivElement>(null);\n  // Extrusion direction. Defaults to down-right — the conventional light\n  // position — so the solid reads correctly before any pointer input.\n  const [dir, setDir] = useState({ x: 0.7, y: 0.7 });\n\n  function handleMove(e: React.MouseEvent<HTMLDivElement>) {\n    const rect = boxRef.current?.getBoundingClientRect();\n    if (!rect) return;\n    const nx = (e.clientX - rect.left) / rect.width - 0.5;\n    const ny = (e.clientY - rect.top) / rect.height - 0.5;\n    // Inverted, so the extrusion trails AWAY from the cursor like a shadow\n    // cast by it rather than leaning toward it.\n    setDir({ x: -nx * 2, y: -ny * 2 });\n  }\n\n  return (\n    <div\n      ref={boxRef}\n      onMouseMove={handleMove}\n      onMouseLeave={() => setDir({ x: 0.7, y: 0.7 })}\n      className=\"flex cursor-default select-none items-center justify-center\"\n    >\n      <span className=\"relative block text-6xl font-black leading-none tracking-tight\">\n        <span className=\"sr-only\">{text}</span>\n\n        <span aria-hidden>\n          {/*\n           * The depth is N stacked copies, each offset one step further along\n           * the light direction and darkened. Because only the OFFSET\n           * direction changes, the solid appears to rotate without any real\n           * 3D — no perspective, no preserve-3d, and so no GPU rasterisation\n           * blurring the glyph edges at fractional transforms.\n           * Furthest layer paints first so nearer ones cover it.\n           */}\n          {Array.from({ length: layers }).map((_, i) => {\n            const step = layers - i;\n            return (\n              <span\n                key={i}\n                className=\"absolute inset-0 block transition-transform duration-200 ease-out\"\n                style={{\n                  transform:\n                    \"translate(\" +\n                    dir.x * depth * step +\n                    \"px, \" +\n                    dir.y * depth * step +\n                    \"px)\",\n                  color: \"rgba(61,123,255,\" + (0.06 + (i / layers) * 0.3) + \")\",\n                }}\n              >\n                {text}\n              </span>\n            );\n          })}\n\n          {/* Front face, drawn last and unoffset. */}\n          <span\n            className=\"relative block\"\n            style={{ color: accentFace ? \"#e8eaee\" : \"#9aa3b2\" }}\n          >\n            {text}\n          </span>\n        </span>\n      </span>\n    </div>\n  );\n}\n","type":"registry:component","target":"components/viberdy/extruded-type-tilt.tsx"}],"meta":{"tier":"free","tags":["text","3d","extrude","hover"],"href":"https://viberdy.dev/library/extruded-type-tilt","aiPrompt":"Create a React + Tailwind component named ExtrudedTypeTilt — oversized display text with a solid extrusion that re-orients toward the pointer.\n\nBehavior:\n- Render the word N+1 times inside a relatively-positioned span: N absolutely-positioned extrusion layers plus one front face in normal flow (the front face is what sizes the box).\n- Each extrusion layer i is translated by (dir.x * depth * step, dir.y * depth * step) where step counts DOWN from N, so the furthest layer paints first and nearer layers cover it.\n- Darken/fade layers with distance so the side wall reads as a solid receding into shadow rather than a flat stack.\n- On mouse move, map pointer position to a -1..1 vector and INVERT it, so the extrusion trails away from the cursor like a shadow cast by it. Default to (0.7, 0.7) — down-right, the conventional light position — so it reads correctly before any input and on mouse leave.\n\nWhy it is built this way (keep this):\n- Only the offset DIRECTION changes, so the solid appears to rotate with no real 3D. Avoiding perspective / transform-style: preserve-3d means the glyphs are never GPU-rasterised at a fractional scale, so the type stays razor sharp. A genuine 3D rotation blurs text.\n\nAccessibility:\n- The word is rendered many times. Mark the whole visual stack aria-hidden and render exactly ONE sr-only copy of the string.\n\nProps: text (string), layers (number), depth (number, px per layer).\n\nOutput a single self-contained \"use client\" component.","license":"https://viberdy.dev/license"}}