liquid-blob
componentry/liquid-blobFreeComponent
Animated liquid morphing blob shapes with mouse interaction that create a beautiful organic background effect.
Live preview
live · rendered by the registry
Rendered by componentry on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://componentry.dev/r/liquid-blob.jsonSource
1"use client"23import { motion, useMotionValue, useSpring } from "framer-motion"4import { useEffect, useRef } from "react"5import { cn } from "@/lib/utils"67interface LiquidBlobProps {8 className?: string9 color?: string10 secondaryColor?: string11 size?: number12 blur?: number13 speed?: number14 opacity?: number15 interactive?: boolean16}1718export function LiquidBlob({19 className,20 color = "#8b5cf6",21 secondaryColor = "#ec4899",22 size = 300,23 blur = 60,24 speed = 8,25 opacity = 0.7,26 interactive = true,27}: LiquidBlobProps) {28 const containerRef = useRef<HTMLDivElement>(null)29 const mouseX = useMotionValue(0)30 const mouseY = useMotionValue(0)3132 const springConfig = { damping: 25, stiffness: 150 }33 const smoothX = useSpring(mouseX, springConfig)34 const smoothY = useSpring(mouseY, springConfig)3536 useEffect(() => {37 if (!interactive) return3839 const container = containerRef.current40 if (!container) return4142 const handleMouseMove = (e: MouseEvent) => {43 const rect = container.getBoundingClientRect()44 const x = e.clientX - rect.left - rect.width / 245 const y = e.clientY - rect.top - rect.height / 246 mouseX.set(x * 0.15)47 mouseY.set(y * 0.15)48 }4950 const handleMouseLeave = () => {51 mouseX.set(0)52 mouseY.set(0)53 }5455 container.addEventListener("mousemove", handleMouseMove)56 container.addEventListener("mouseleave", handleMouseLeave)5758 return () => {59 container.removeEventListener("mousemove", handleMouseMove)60 container.removeEventListener("mouseleave", handleMouseLeave)61 }62 }, [interactive, mouseX, mouseY])6364 return (65 <div66 ref={containerRef}67 className={cn("pointer-events-auto absolute inset-0 overflow-hidden", className)}68 >69 <motion.div70 className="absolute rounded-full"71 style={{72 width: size,73 height: size,74 background: `radial-gradient(circle, ${color} 0%, ${secondaryColor} 100%)`,75 filter: `blur(${blur}px)`,76 opacity,77 left: "20%",78 top: "20%",79 x: smoothX,80 y: smoothY,81 }}82 animate={{83 scale: [1, 1.2, 0.9, 1.1, 1],84 borderRadius: [85 "60% 40% 30% 70% / 60% 30% 70% 40%",86 "30% 60% 70% 40% / 50% 60% 30% 60%",87 "60% 40% 30% 70% / 60% 30% 70% 40%",88 "40% 60% 60% 40% / 70% 30% 50% 60%",89 "60% 40% 30% 70% / 60% 30% 70% 40%",90 ],91 }}92// … truncated
More from componentry
All 59 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Animated Gradientanimated-gradient | componentry | Components | Free | no deps | |
| ASCII Effectascii-effect | componentry | Components | Free | no deps | |
| Aurora Flowaurora-flow | componentry | Components | Free | no deps | |
| auth-modalauth-modal | componentry | Components | Free | no deps | |
| border-beamborder-beam | componentry | Components | Free | no deps | |
| circuit-boardcircuit-board | componentry | Components | Free | no deps | |
| closing-plasmaclosing-plasma | componentry | Components | Free | no deps | |
| collection-surfercollection-surfer | componentry | Components | Free | no deps |
