"use client"; import { useAnimate, useReducedMotion } from "motion/react"; type LiquidLettersProps = { text: string; className?: string; /** Seconds one wobble takes. */ duration?: number; }; /* LiquidLetters: run the pointer over the text and each letter it touches wobbles like jelly, squashing and springing back. */ export function LiquidLetters({ text, className = "", duration = 0.8 }: LiquidLettersProps) { const reduce = useReducedMotion(); const [scope, animate] = useAnimate(); const wobble = (el: HTMLElement) => { if (reduce) return; animate(el, { scaleX: [1, 1.3, 0.8, 1.1, 0.95, 1], scaleY: [1, 0.7, 1.2, 0.9, 1.05, 1] }, { duration, ease: "easeOut" }); }; const words = text.split(" "); return ( {text} {words.map((word, w) => ( {[...word].map((ch, i) => ( wobble(e.currentTarget)}> {ch} ))} {w < words.length - 1 && " "} ))} ); }