{"$schema":"https://ui.shadcn.com/schema/registry-item.json","author":"Eduardo Calvo <educlopez93@gmail.com>","css":{},"dependencies":["motion"],"description":"A StaggerFromCenter text animation component for SmoothUI.","devDependencies":[],"files":[{"content":"\"use client\";\n\nimport { motion, useInView, useReducedMotion } from \"motion/react\";\nimport { useRef } from \"react\";\n\nexport interface StaggerFromCenterProps {\n  children: string;\n  className?: string;\n  /** Delay before the animation starts, in milliseconds. */\n  delay?: number;\n  /** Per-step stagger between characters, in milliseconds. */\n  stagger?: number;\n  /** Animate only once the text scrolls into view. */\n  triggerOnView?: boolean;\n}\n\nconst DURATION_S = 0.62;\nconst MS = 1000;\n// Apple-ish ease-out for center-out reveal.\nconst EASE = [0.22, 1, 0.36, 1] as const;\n\n/**\n * StaggerFromCenter — characters reveal from the center outward to\n * emphasize the keyword core. Delay is computed by distance from center,\n * not linear index. From the animate-text catalog (`stagger-from-center`).\n */\nexport default function StaggerFromCenter({\n  children,\n  className = \"\",\n  delay = 0,\n  stagger = 22,\n  triggerOnView = false,\n}: StaggerFromCenterProps) {\n  const ref = useRef<HTMLSpanElement>(null);\n  const inView = useInView(ref, { once: true });\n  const shouldReduceMotion = useReducedMotion();\n  const play = (!triggerOnView || inView) && !shouldReduceMotion;\n  const characters = Array.from(children);\n  const center = (characters.length - 1) / 2;\n\n  return (\n    <span aria-label={children} className={className} ref={ref}>\n      {characters.map((char, index) => {\n        const distance = Math.abs(index - center);\n        return (\n          <motion.span\n            animate={\n              play ? { filter: \"blur(0px)\", opacity: 1, y: 0 } : undefined\n            }\n            aria-hidden=\"true\"\n            initial={\n              shouldReduceMotion\n                ? { opacity: 1 }\n                : { filter: \"blur(3px)\", opacity: 0, y: 12 }\n            }\n            // biome-ignore lint/suspicious/noArrayIndexKey: characters have no stable id\n            key={index}\n            style={{ display: \"inline-block\", whiteSpace: \"pre\" }}\n            transition={\n              shouldReduceMotion\n                ? { duration: 0 }\n                : {\n                    delay: delay / MS + (distance * stagger) / MS,\n                    duration: DURATION_S,\n                    ease: EASE,\n                  }\n            }\n          >\n            {char === \" \" ? \" \" : String(char)}\n          </motion.span>\n        );\n      })}\n    </span>\n  );\n}\n","path":"index.tsx","target":"components/smoothui/stagger-from-center/index.tsx","type":"registry:ui"}],"name":"stagger-from-center","registryDependencies":[],"title":"Stagger From Center","type":"registry:ui"}