{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "liquid-button",
  "type": "registry:ui",
  "title": "Liquid Button",
  "description": "An interactive gooey liquid dripping hover effect button.",
  "dependencies": [
    "react",
    "motion",
    "clsx",
    "tailwind-merge"
  ],
  "devDependencies": [
    "@types/react"
  ],
  "registryDependencies": [],
  "files": [
    {
      "path": "ui/liquid-button.tsx",
      "content": "'use client';\n\nimport React, { useRef, useId, useState } from 'react';\nimport {\n  motion,\n  useMotionValue,\n  useSpring,\n  useTransform,\n  type MotionValue,\n  type HTMLMotionProps,\n} from 'motion/react';\nimport { clsx, type ClassValue } from 'clsx';\nimport { twMerge } from 'tailwind-merge';\n\nfunction cn(...inputs: ClassValue[]) {\n  return twMerge(clsx(inputs));\n}\n\nexport interface LiquidButtonProps extends HTMLMotionProps<'button'> {\n  text?: string;\n  children?: React.ReactNode;\n  className?: string;\n  backgroundColor?: string;\n  textColor?: string;\n  isDripping?: boolean;\n}\n\nexport default function LiquidButton({\n  text = 'Hover me',\n  children,\n  className,\n  backgroundColor = 'bg-black dark:bg-orange-400',\n  textColor = 'text-white dark:text-neutral-50',\n  isDripping = false,\n  onClick,\n  ...props\n}: LiquidButtonProps) {\n  const containerRef = useRef<HTMLDivElement>(null);\n  const rawId = useId();\n  const filterId = `liquid-goo-${rawId.replace(/[^a-zA-Z0-9_-]/g, '')}`;\n\n  const mouseX = useMotionValue(0);\n  const springX = useSpring(mouseX, { stiffness: 320, damping: 22 });\n  const [isHovered, setIsHovered] = useState(false);\n\n  // Normalized cursor percentage (0% to 100%) for interactive follower droplet\n  const cursorPercent = useMotionValue(50);\n  const springCursorPercent = useSpring(cursorPercent, { stiffness: 280, damping: 24 });\n\n  const handleMouseMove = (e: React.MouseEvent) => {\n    if (!containerRef.current) return;\n    const rect = containerRef.current.getBoundingClientRect();\n    const relativeX = e.clientX - rect.left;\n    const centeredX = relativeX - rect.width / 2;\n    mouseX.set(centeredX);\n\n    // Keep interactive drop clamped inside 16% - 84% of button width\n    const pct = Math.max(16, Math.min(84, (relativeX / rect.width) * 100));\n    cursorPercent.set(pct);\n  };\n\n  const handleMouseEnter = () => {\n    setIsHovered(true);\n  };\n\n  const handleMouseLeave = () => {\n    setIsHovered(false);\n    mouseX.set(0);\n  };\n\n  const handleTouchStart = (e: React.TouchEvent) => {\n    setIsHovered(true);\n    if (!containerRef.current || e.touches.length === 0) return;\n    const rect = containerRef.current.getBoundingClientRect();\n    const relativeX = e.touches[0].clientX - rect.left;\n    const centeredX = relativeX - rect.width / 2;\n    mouseX.set(centeredX);\n    const pct = Math.max(16, Math.min(84, (relativeX / rect.width) * 100));\n    cursorPercent.set(pct);\n  };\n\n  const handleTouchMove = (e: React.TouchEvent) => {\n    if (!containerRef.current || e.touches.length === 0) return;\n    const rect = containerRef.current.getBoundingClientRect();\n    const relativeX = e.touches[0].clientX - rect.left;\n    const centeredX = relativeX - rect.width / 2;\n    mouseX.set(centeredX);\n    const pct = Math.max(16, Math.min(84, (relativeX / rect.width) * 100));\n    cursorPercent.set(pct);\n  };\n\n  const handleTouchEnd = () => {\n    setIsHovered(false);\n    mouseX.set(0);\n  };\n\n  const activeState = isDripping || isHovered ? 'hover' : 'initial';\n\n  return (\n    <div\n      ref={containerRef}\n      className={cn('relative inline-flex items-center justify-center p-6 select-none', className)}\n      onMouseMove={handleMouseMove}\n      onMouseEnter={handleMouseEnter}\n      onMouseLeave={handleMouseLeave}\n      onTouchStart={handleTouchStart}\n      onTouchMove={handleTouchMove}\n      onTouchEnd={handleTouchEnd}\n      onTouchCancel={handleTouchEnd}\n    >\n      {/* High-definition SVG Gooey Filter with wide region to prevent clipping */}\n      <svg className=\"absolute h-0 w-0 overflow-hidden\" aria-hidden=\"true\">\n        <defs>\n          <filter\n            id={filterId}\n            colorInterpolationFilters=\"sRGB\"\n            x=\"-30%\"\n            y=\"-20%\"\n            width=\"160%\"\n            height=\"380%\"\n          >\n            <feGaussianBlur in=\"SourceGraphic\" stdDeviation=\"5.5\" result=\"blur\" />\n            <feColorMatrix\n              in=\"blur\"\n              mode=\"matrix\"\n              values=\"1 0 0 0 0  0 1 0 0 0  0 0 1 0 0  0 0 0 20 -9\"\n              result=\"goo\"\n            />\n            <feComposite in=\"SourceGraphic\" in2=\"goo\" operator=\"atop\" />\n          </filter>\n        </defs>\n      </svg>\n\n      {/* Button wrapper with snappy spring press interaction */}\n      <motion.button\n        type=\"button\"\n        onClick={onClick}\n        className={cn(\n          'group relative inline-flex cursor-pointer items-center justify-center rounded-lg border-0 bg-transparent p-0 outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2'\n        )}\n        whileHover={{ scale: 1.025 }}\n        whileTap={{ scale: 0.96 }}\n        transition={{ type: 'spring', stiffness: 450, damping: 22 }}\n        {...props}\n      >\n        {/* Liquid Body Layer (Processed through SVG Gooey Filter) */}\n        <div\n          className=\"relative z-10 w-full rounded-lg\"\n          style={{ filter: `url(#${filterId})` }}\n        >\n          {/* Main Solid Button Base with 3D liquid volume */}\n          <div\n            className={cn(\n              'relative z-10 flex min-h-[46px] min-w-[144px] items-center justify-center rounded-lg px-7 py-2.5 transition-colors duration-200 overflow-hidden',\n              'shadow-[inset_0_1.5px_1px_rgba(255,255,255,0.7),inset_0_-2px_4px_rgba(0,0,0,0.12),0_4px_12px_rgba(0,0,0,0.08)] dark:shadow-[inset_0_1.5px_1px_rgba(255,255,255,0.85),inset_0_-2px_5px_rgba(0,0,0,0.25),0_6px_18px_rgba(0,0,0,0.5)]',\n              backgroundColor\n            )}\n          >\n            {/* Invisible layout spacer so the button base conforms precisely to content dimensions */}\n            <span className=\"invisible select-none flex items-center justify-center gap-2 text-sm font-semibold tracking-wide md:text-base whitespace-nowrap\">\n              {children || text}\n            </span>\n\n            {/* Glossy Liquid Specular Sheen (Curved meniscus highlight) */}\n            <div className=\"pointer-events-none absolute inset-x-3 top-0.5 h-[38%] rounded-t-full bg-gradient-to-b from-white/35 via-white/10 to-transparent dark:from-white/45 dark:via-white/15\" />\n          </div>\n\n          {/* Curated Snappy Liquid Droplets */}\n          <LiquidDrop\n            left=\"16%\"\n            size=\"w-3.5 h-3.5 md:w-4 md:h-4\"\n            delay={0.05}\n            duration={1.25}\n            mouseX={springX}\n            backgroundColor={backgroundColor}\n            activeState={activeState}\n          />\n          <LiquidDrop\n            left=\"35%\"\n            size=\"w-4.5 h-4.5 md:w-5 md:h-5\"\n            delay={0.45}\n            duration={1.4}\n            mouseX={springX}\n            backgroundColor={backgroundColor}\n            activeState={activeState}\n          />\n          <LiquidDrop\n            left=\"65%\"\n            size=\"w-3 h-3 md:w-3.5 md:h-3.5\"\n            delay={0.85}\n            duration={1.15}\n            mouseX={springX}\n            backgroundColor={backgroundColor}\n            activeState={activeState}\n          />\n          <LiquidDrop\n            left=\"84%\"\n            size=\"w-4 h-4 md:w-4.5 md:h-4.5\"\n            delay={0.2}\n            duration={1.35}\n            mouseX={springX}\n            backgroundColor={backgroundColor}\n            activeState={activeState}\n          />\n\n          {/* Interactive Cursor Follower Droplet */}\n          <CursorFollowerDrop\n            cursorPercent={springCursorPercent}\n            backgroundColor={backgroundColor}\n            activeState={activeState}\n          />\n        </div>\n\n        {/* Crisp Unfiltered Foreground Content (Centered over button, never blurred by SVG filter) */}\n        <span\n          className={cn(\n            'pointer-events-none absolute inset-0 z-20 flex items-center justify-center gap-2 px-7 py-2.5 text-sm font-semibold tracking-wide transition-colors md:text-base select-none whitespace-nowrap',\n            textColor\n          )}\n        >\n          {children || text}\n        </span>\n      </motion.button>\n    </div>\n  );\n}\n\n// ─── Snappy Liquid Droplet with Fluid Surface Tension Physics ─────────────────\nfunction LiquidDrop({\n  left,\n  size,\n  delay,\n  duration,\n  mouseX,\n  backgroundColor,\n  activeState,\n}: {\n  left: string;\n  size: string;\n  delay: number;\n  duration: number;\n  mouseX: MotionValue<number>;\n  backgroundColor: string;\n  activeState: 'initial' | 'hover';\n}) {\n  const factor = duration * 4.5;\n  const x = useTransform(mouseX, [-150, 150], [-factor, factor]);\n\n  return (\n    <motion.div\n      className={cn(\n        'absolute bottom-1 -z-10 rounded-lg will-change-transform pointer-events-none',\n        size,\n        backgroundColor\n      )}\n      style={{ left, x }}\n      initial=\"initial\"\n      animate={activeState}\n      variants={{\n        initial: {\n          y: 0,\n          scale: 0,\n          opacity: 0,\n          transition: { duration: 0.2, ease: 'easeOut' },\n        },\n        hover: {\n          y: [0, 5, 18, 32, 60, 85],\n          scale: [0, 1.15, 1, 1, 0.85, 0],\n          scaleX: [0.8, 1.45, 0.65, 1.18, 0.92, 0.55],\n          scaleY: [0.8, 0.68, 1.65, 0.92, 1.08, 0.55],\n          opacity: [0, 1, 1, 1, 0.85, 0],\n          transition: {\n            duration,\n            repeat: Infinity,\n            ease: ['easeOut', 'easeInOut', 'easeIn', 'easeIn', 'easeIn'],\n            times: [0, 0.22, 0.48, 0.6, 0.82, 1],\n            delay,\n          },\n        },\n      }}\n    />\n  );\n}\n\n// ─── Interactive Cursor Droplet ──────────────────────────────────────────────\nfunction CursorFollowerDrop({\n  cursorPercent,\n  backgroundColor,\n  activeState,\n}: {\n  cursorPercent: MotionValue<number>;\n  backgroundColor: string;\n  activeState: 'initial' | 'hover';\n}) {\n  const leftStyle = useTransform(cursorPercent, (p) => `${p}%`);\n\n  return (\n    <motion.div\n      className={cn(\n        'absolute bottom-1 -z-10 h-4.5 w-4.5 rounded-lg will-change-transform pointer-events-none md:h-5 md:w-5',\n        backgroundColor\n      )}\n      style={{ left: leftStyle }}\n      initial=\"initial\"\n      animate={activeState}\n      variants={{\n        initial: {\n          y: 0,\n          scale: 0,\n          opacity: 0,\n          transition: { duration: 0.2 },\n        },\n        hover: {\n          y: [0, 5, 18, 32, 58, 82],\n          scale: [0, 1.15, 1, 1, 0.85, 0],\n          scaleX: [0.8, 1.45, 0.65, 1.18, 0.92, 0.55],\n          scaleY: [0.8, 0.68, 1.65, 0.92, 1.08, 0.55],\n          opacity: [0, 1, 1, 1, 0.85, 0],\n          transition: {\n            duration: 1.25,\n            repeat: Infinity,\n            ease: ['easeOut', 'easeInOut', 'easeIn', 'easeIn', 'easeIn'],\n            times: [0, 0.22, 0.48, 0.6, 0.82, 1],\n            delay: 0.1,\n          },\n        },\n      }}\n    />\n  );\n}\n",
      "type": "registry:ui"
    }
  ]
}