{ "$schema": "https://ui.shadcn.com/schema/registry-item.json", "name": "lightning-text", "title": "Lightning Text", "description": "Text with Lightning effect animation.", "dependencies": [ "gsap" ], "files": [ { "path": "registry/components/lightning-text.tsx", "content": "\"use client\";\n\nimport gsap from \"gsap\";\nimport { SplitText } from \"gsap/SplitText\";\nimport { ReactNode, useEffect, useRef } from \"react\";\n\ngsap.registerPlugin(SplitText);\n\ninterface LightningTextProps {\n children: ReactNode;\n color?: string;\n repeatDelay?: number;\n stagger?: number;\n}\n\nexport function LightningText({\n children,\n color = \"#2b6bbb\",\n repeatDelay = 1.5,\n stagger = 0.04,\n}: LightningTextProps) {\n const textRef = useRef(null);\n\n useEffect(() => {\n if (!textRef.current) return;\n\n const split = new SplitText(textRef.current, { type: \"chars\" });\n\n const tl = gsap.timeline({\n repeat: -1,\n repeatDelay: repeatDelay,\n });\n\n tl.call(() => {\n if (!textRef.current) return;\n textRef.current.classList.add(\"lightning-blink\");\n split.chars.forEach((el, index) => {\n const char = el as HTMLElement;\n char.style.setProperty(\"--lightning-color\", color);\n char.style.animationDelay = `${index * stagger}s`;\n char.classList.add(\"lightning-char\");\n });\n });\n\n tl.to({}, { duration: 1.5 });\n\n tl.call(() => {\n if (!textRef.current) return;\n textRef.current.classList.remove(\"lightning-blink\");\n split.chars.forEach((el) =>\n (el as HTMLElement).classList.remove(\"lightning-char\"),\n );\n });\n\n return () => {\n tl.kill();\n split.revert();\n };\n }, [color, repeatDelay, stagger]);\n\n return (\n <>\n \n \n {children}\n \n \n );\n}\n", "type": "registry:component" } ], "type": "registry:block" }