shadcn.io is not affiliated with official shadcn/ui
Liquid Text makes a line behave like liquid: every letter sways on its own, two slow swells out of step, and where neighbours come close they melt into one blob and pull apart again, like droplets on glass. While the pointer is over it the letters sway further and run into each other.
Use it for a hero word or a short title in a heavy weight, at a large size. For letters that rise and fall on a wave without merging, use Wave Text; for a pointer that bends the text, Elastic Text. Each letter's sway is two CSS keyframe animations, added to your stylesheet by the install and phased by the letter's place, so it never quite repeats; an SVG goo filter (a blur, then a sharp cut of its edge) merges the letters that touch. With reduced motion the letters hold still.
Installation
Usage
import { LiquidText } from "@/components/ui/liquid-text";<h1 className="font-black text-6xl">
<LiquidText text="Liquid" />
</h1>Demos
Intensity
intensity is how far the letters sway: subtle, medium or strong. Hovering eases any of them out to nearly twice as far.
Blur
blur is how far apart letters can be and still melt together, in pixels, 2 by default. More makes thick gel; on smaller text use less, about a twentieth of the font size, or the holes in letters such as e and a fill in.
Accessibility
Screen readers read the text once, from a visually hidden copy; the swaying letters are hidden from them. The goo rounds letters off, so keep it to large, heavy text, a headline of 36 px and up, and check it still reads. With reduced motion the letters hold still, and in forced-colors mode the filter is dropped.
FAQ
How do the letters melt together?
An SVG filter blurs the letters, then cuts the blur's edge sharp at half strength: alone, a letter keeps its shape with rounded corners; when two come close, their blurs overlap past half and the cut joins them in one blob.
What size and weight suit it?
Large and heavy: font-black from about text-4xl up. The blur is in pixels, so the same blur softens small text more; lower it for smaller sizes, and keep normal letter spacing so the letters have room to meet and part.
Does the motion loop visibly?
Hardly: each letter adds two swells of different lengths, 1.7 and 2.9 seconds, each started at a different point for every letter, so the pattern takes a long time to come round again.
Does it work in every browser?
SVG filters on HTML text work in current Chrome, Edge, Firefox and Safari. The filter redraws the text on every frame, which Safari does more slowly: keep it to one headline per page.
API Reference
LiquidText
<span> data-slot="liquid-text"
textstring
The text.
blur?number
How far apart letters can be and still melt together: the blur the goo is made from, in pixels. Keep it near a twentieth of the font size, or the holes in letters fill in.
- Default
2
intensity?"subtle" | "medium" | "strong"
How far the letters sway; while the pointer is over the text they sway nearly twice as far and run into each other.
- Type
"subtle" | "medium" | "strong"- Default
"medium"
render?ReactElement | ((props: object, state: object) => ReactElement)
Replace the host element or compose it with another component.
- Type
ReactElement | ((props: object, state: object) => ReactElement)
className?string
Merged with the part's classes.
--liquid-text-goostring--liquid-text-swaystring
How far a letter sways (0.06em at medium).
Related
- Pro
Wave Text
MotionLetters on a wave, never merging
- Pro
Elastic Text
InteractiveLetters stretch as the pointer passes
- Pro
Ripple Text
InteractiveA ripple from wherever you click
- Pro
Drift Text
MotionLetters floating apart on their own
- Pro
Wobble Text
MotionJelly letters that rock in place
- Pro
Breathe in, breathe out
Breathing Text
MotionThe whole line breathing as one