Text Effects
LiquidLetters
Run the pointer over the text and each letter it touches wobbles like jelly, squashing and springing back.
Download
- React
- Tailwind CSS v4
- motion
components/ui/liquid-letters.tsx
"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<HTMLSpanElement>();
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 (
<span ref={scope} className={className}>
<span className="sr-only">{text}</span>
<span aria-hidden>
{words.map((word, w) => (
<span key={w}>
<span className="inline-block whitespace-nowrap">
{[...word].map((ch, i) => (
<span key={i} className="inline-block origin-bottom" onPointerEnter={(e) => wobble(e.currentTarget)}>
{ch}
</span>
))}
</span>
{w < words.length - 1 && " "}
</span>
))}
</span>
</span>
);
}
1. Install the dependency.
npm i motion2. Paste the Code tab into
components/ui/liquid-letters.tsx. The styles are Tailwind CSS v4 classes.3. Use it. This is the preview above:
app/liquid-letters-demo.tsx
import { LiquidLetters } from "@/components/ui/liquid-letters"; export default function LiquidLettersExample() { return ( <div className="grid h-full place-items-center bg-[#d9fbe9] p-6"> <div className="text-center"> <LiquidLetters text="Jelly type" className="text-[clamp(44px,9vw,104px)] font-black tracking-tight text-[#0f1a17]" /> <p className="mt-3 text-xs text-[#0f1a17]/50">Run the pointer over the letters</p> </div> </div> ); }
Props
| Name | Type | Default | What it does |
|---|---|---|---|
| text | string | — | Text to show. |
| duration | number | 0.8 | Seconds one wobble takes. |
| className | string | "" | Type styles for the text. |