{ "$schema": "https://ui.shadcn.com/schema/registry-item.json", "name": "bubble-background", "type": "registry:ui", "title": "Bubble Background", "description": "An interactive background featuring smoothly animated gradient bubbles, creating a playful, dynamic, and visually engaging backdrop.", "dependencies": [ "motion" ], "files": [ { "path": "registry/backgrounds/bubble/index.tsx", "content": "'use client';\n\nimport * as React from 'react';\nimport {\n motion,\n type SpringOptions,\n useMotionValue,\n useSpring,\n} from 'motion/react';\n\nimport { cn } from '@/lib/utils';\n\ntype BubbleBackgroundProps = React.ComponentProps<'div'> & {\n interactive?: boolean;\n transition?: SpringOptions;\n colors?: {\n first: string;\n second: string;\n third: string;\n fourth: string;\n fifth: string;\n sixth: string;\n };\n};\n\nfunction BubbleBackground({\n ref,\n className,\n children,\n interactive = false,\n transition = { stiffness: 100, damping: 20 },\n colors = {\n first: '18,113,255',\n second: '221,74,255',\n third: '0,220,255',\n fourth: '200,50,50',\n fifth: '180,180,50',\n sixth: '140,100,255',\n },\n ...props\n}: BubbleBackgroundProps) {\n const containerRef = React.useRef(null);\n React.useImperativeHandle(ref, () => containerRef.current as HTMLDivElement);\n\n const mouseX = useMotionValue(0);\n const mouseY = useMotionValue(0);\n const springX = useSpring(mouseX, transition);\n const springY = useSpring(mouseY, transition);\n\n React.useEffect(() => {\n if (!interactive) return;\n\n const currentContainer = containerRef.current;\n if (!currentContainer) return;\n\n const handleMouseMove = (e: MouseEvent) => {\n const rect = currentContainer.getBoundingClientRect();\n const centerX = rect.left + rect.width / 2;\n const centerY = rect.top + rect.height / 2;\n mouseX.set(e.clientX - centerX);\n mouseY.set(e.clientY - centerY);\n };\n\n currentContainer?.addEventListener('mousemove', handleMouseMove);\n return () =>\n currentContainer?.removeEventListener('mousemove', handleMouseMove);\n }, [interactive, mouseX, mouseY]);\n\n return (\n \n \n\n \n \n \n \n \n \n \n \n \n\n \n \n\n \n
\n \n\n \n
\n \n\n \n\n \n
\n \n\n {interactive && (\n \n )}\n
\n\n {children}\n
\n );\n}\n\nexport { BubbleBackground, type BubbleBackgroundProps };\n", "type": "registry:ui", "target": "components/animate-ui/backgrounds/bubble.tsx" } ] }