{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"expanding-arrow-button","type":"registry:component","title":"Animated CTA Buttons Expanding Arrow Button","description":"An accent tile that expands into a dotted-arrow trail on hover or focus.","author":"Saurabh <saurabh10102@gmail.com>","dependencies":["clsx","motion","tailwind-merge"],"registryDependencies":[],"files":[{"path":"components/motion/expanding-arrow-button.tsx","type":"registry:component","target":"@components/motion/expanding-arrow-button.tsx","content":"\"use client\";\n// beui.dev/components/motion/expanding-arrow-button\n\nimport {\n  motion,\n  useReducedMotion,\n  type HTMLMotionProps,\n} from \"motion/react\";\nimport {\n  forwardRef,\n  useState,\n  type FocusEvent,\n  type MouseEvent,\n  type ReactNode,\n} from \"react\";\nimport { EASE_OUT, SPRING_LAYOUT, SPRING_PRESS } from \"@/lib/ease\";\nimport { useHoverCapable } from \"@/lib/hooks/use-hover-capable\";\nimport { cn } from \"@/lib/utils\";\n\nexport interface ExpandingArrowButtonProps extends Omit<\n  HTMLMotionProps<\"button\">,\n  \"children\"\n> {\n  children: ReactNode;\n  accentClassName?: string;\n  labelClassName?: string;\n}\n\nconst ARROW_OPACITY = [1, 0.78, 0.54, 0.32, 0.16] as const;\n\nfunction DottedChevron({ className }: { className?: string }) {\n  return (\n    <svg\n      viewBox=\"0 0 20 28\"\n      fill=\"none\"\n      aria-hidden=\"true\"\n      className={className}\n    >\n      <circle cx=\"4\" cy=\"4\" r=\"2\" fill=\"currentColor\" />\n      <circle cx=\"10\" cy=\"9\" r=\"2\" fill=\"currentColor\" />\n      <circle cx=\"16\" cy=\"14\" r=\"2\" fill=\"currentColor\" />\n      <circle cx=\"10\" cy=\"19\" r=\"2\" fill=\"currentColor\" />\n      <circle cx=\"4\" cy=\"24\" r=\"2\" fill=\"currentColor\" />\n    </svg>\n  );\n}\n\nexport const ExpandingArrowButton = forwardRef<\n  HTMLButtonElement,\n  ExpandingArrowButtonProps\n>(function ExpandingArrowButton(\n  {\n    children,\n    className,\n    accentClassName,\n    labelClassName,\n    disabled,\n    onMouseEnter,\n    onMouseLeave,\n    onFocus,\n    onBlur,\n    ...rest\n  },\n  ref,\n) {\n  const reduce = useReducedMotion();\n  const canHover = useHoverCapable();\n  const [hovered, setHovered] = useState(false);\n  const [focused, setFocused] = useState(false);\n  const active = !disabled && ((canHover && hovered) || focused);\n  const layoutTransition = reduce ? { duration: 0 } : SPRING_LAYOUT;\n\n  const handleMouseEnter = (event: MouseEvent<HTMLButtonElement>) => {\n    setHovered(true);\n    onMouseEnter?.(event);\n  };\n\n  const handleMouseLeave = (event: MouseEvent<HTMLButtonElement>) => {\n    setHovered(false);\n    onMouseLeave?.(event);\n  };\n\n  const handleFocus = (event: FocusEvent<HTMLButtonElement>) => {\n    setFocused(true);\n    onFocus?.(event);\n  };\n\n  const handleBlur = (event: FocusEvent<HTMLButtonElement>) => {\n    setFocused(false);\n    onBlur?.(event);\n  };\n\n  return (\n    <motion.button\n      ref={ref}\n      type=\"button\"\n      disabled={disabled}\n      onMouseEnter={handleMouseEnter}\n      onMouseLeave={handleMouseLeave}\n      onFocus={handleFocus}\n      onBlur={handleBlur}\n      whileTap={reduce || disabled ? undefined : { scale: 0.97 }}\n      transition={SPRING_PRESS}\n      className={cn(\n        \"relative inline-flex h-16 min-w-72 items-center overflow-hidden rounded-[22px] bg-neutral-950 p-1.5 text-white select-none\",\n        \"outline-none focus-visible:ring-2 focus-visible:ring-lime-300 focus-visible:ring-offset-2 focus-visible:ring-offset-background\",\n        \"disabled:pointer-events-none disabled:opacity-50\",\n        className,\n      )}\n      {...rest}\n    >\n      <motion.span\n        layout=\"size\"\n        aria-hidden=\"true\"\n        transition={layoutTransition}\n        style={{\n          width: active ? \"calc(100% - 12px)\" : 52,\n          borderRadius: 16,\n        }}\n        className={cn(\n          \"absolute inset-y-1.5 left-1.5 z-10 overflow-hidden bg-lime-300 text-neutral-950\",\n          accentClassName,\n        )}\n      >\n        <motion.span\n          animate={{ opacity: active ? 0 : 1 }}\n          transition={{ duration: reduce ? 0 : 0.1, ease: EASE_OUT }}\n          className=\"absolute inset-0 grid place-items-center\"\n        >\n          <DottedChevron className=\"h-7 w-5\" />\n        </motion.span>\n\n        <span className=\"absolute inset-0 flex items-center justify-around px-3\">\n          {ARROW_OPACITY.map((opacity, index) => (\n            <motion.span\n              key={opacity}\n              animate={{\n                opacity: active ? 1 : 0,\n                transform:\n                  active && !reduce ? \"translateX(0px)\" : \"translateX(-6px)\",\n              }}\n              transition={{\n                duration: reduce ? 0 : 0.18,\n                delay: active && !reduce ? 0.04 + index * 0.025 : 0,\n                ease: EASE_OUT,\n              }}\n              style={{ color: `rgb(10 10 10 / ${opacity})` }}\n              className=\"inline-grid place-items-center\"\n            >\n              <DottedChevron className=\"h-7 w-5\" />\n            </motion.span>\n          ))}\n        </span>\n      </motion.span>\n\n      <motion.span\n        animate={{\n          opacity: active ? 0 : 1,\n          transform:\n            active && !reduce ? \"translateX(6px)\" : \"translateX(0px)\",\n        }}\n        transition={{ duration: reduce ? 0 : 0.12, ease: EASE_OUT }}\n        className={cn(\n          \"relative z-0 ml-[76px] mr-5 whitespace-nowrap text-lg font-medium tracking-[-0.02em]\",\n          labelClassName,\n        )}\n      >\n        {children}\n      </motion.span>\n    </motion.button>\n  );\n});\n"},{"path":"lib/ease.ts","type":"registry:lib","target":"@lib/ease.ts","content":"// Shared motion tokens. Easing curves mirror the CSS custom properties in\n// globals.css; springs are the canonical physics used across components.\n// Strong custom variants — defaults like `ease-in`/`ease-out` feel weak.\n\nexport const EASE_OUT = [0.16, 1, 0.3, 1] as const;\nexport const EASE_IN_OUT = [0.77, 0, 0.175, 1] as const;\nexport const EASE_DRAWER = [0.32, 0.72, 0, 1] as const;\n\n/** CSS string form of EASE_OUT for inline style transitions. */\nexport const EASE_OUT_CSS = \"cubic-bezier(0.16, 1, 0.3, 1)\";\n\n/** Press feedback on buttons and other tappable surfaces. */\nexport const SPRING_PRESS = {\n  type: \"spring\",\n  stiffness: 500,\n  damping: 30,\n  mass: 0.6,\n} as const;\n\n/** Content swaps — label/icon slots trading places inside a control. */\nexport const SPRING_SWAP = {\n  type: \"spring\",\n  stiffness: 460,\n  damping: 30,\n  mass: 0.55,\n} as const;\n\n/** Overlay panel entrances — modals and sheets summoned by pointer. */\nexport const SPRING_PANEL = {\n  type: \"spring\",\n  stiffness: 420,\n  damping: 40,\n  mass: 0.5,\n} as const;\n\n/** Shared-layout glides — pills, indicators and panels morphing between positions. */\nexport const SPRING_LAYOUT = {\n  type: \"spring\",\n  stiffness: 360,\n  damping: 32,\n  mass: 0.6,\n} as const;\n\n/** Cursor-follow physics for decorative mouse tracking (magnetic, tilt, dock). */\nexport const SPRING_MOUSE = {\n  stiffness: 200,\n  damping: 15,\n  mass: 0.3,\n} as const;\n\n/** Dragged handles and fills (sliders) — critically damped `useSpring` config,\n * so the value follows the pointer butterily and never rebounds off an end. */\nexport const SPRING_GLIDE = {\n  stiffness: 700,\n  damping: 50,\n  mass: 0.5,\n} as const;\n"},{"path":"lib/hooks/use-hover-capable.ts","type":"registry:hook","target":"@lib/hooks/use-hover-capable.ts","content":"\"use client\";\n\nimport { useEffect, useState } from \"react\";\n\n/**\n * Returns true only on devices that have a true hover (mouse / trackpad).\n * Touch devices fire phantom `:hover` on tap that sticks until tap-elsewhere\n * — gate hover-only effects (scale lifts, magnetic pulls) behind this.\n */\nexport function useHoverCapable() {\n  const [canHover, setCanHover] = useState(false);\n\n  useEffect(() => {\n    if (typeof window === \"undefined\" || !window.matchMedia) return;\n    const mq = window.matchMedia(\"(hover: hover) and (pointer: fine)\");\n    const update = () => setCanHover(mq.matches);\n    update();\n    mq.addEventListener?.(\"change\", update);\n    return () => mq.removeEventListener?.(\"change\", update);\n  }, []);\n\n  return canHover;\n}\n"},{"path":"lib/utils.ts","type":"registry:lib","target":"@lib/utils.ts","content":"import { clsx, type ClassValue } from \"clsx\"\nimport { twMerge } from \"tailwind-merge\"\n\nexport function cn(...inputs: ClassValue[]) {\n  return twMerge(clsx(inputs))\n}\n"}]}