shadcn.io is not affiliated with official shadcn/ui
Wobble Text makes a word jiggle like jelly: every letter rocks from side to side and swells a little as it swings back, each a beat behind the one before, so the word moves as one soft piece. Point at it and the wobble grows, then eases back when the pointer leaves.
Use it for a playful word: a game's title, a call to action, a 404, a kids' app. For letters that ride a wave across the line instead of rocking in place, use Wave Text; for letters that squash flat and spring up, Stretch Text. The motion is two CSS keyframe animations the install adds to your stylesheet, a rock and a swell, both scaled by one registered CSS property that a transition eases on hover, so the wobble grows without changing pace. There's no animation library and no JavaScript. With reduced motion the text is still.
Installation
Usage
import { WobbleText } from "@/components/ui/wobble-text";<h1>
<WobbleText text="Jelly time" />
</h1>Demos
Intensity
intensity is how far each letter rocks and swells: subtle for a hint, medium, the default, for a headline, strong for a word that should be silly. duration is one wobble, there and back, 800 ms by default.
Link
Inside a link or a button, the text wobbles harder while the pointer is over it or while the link has keyboard focus, so it answers both. hover={false} keeps the wobble the same throughout.
Accessibility
Screen readers read the text once, as plain text, from a visually hidden copy; the wobbling letters are hidden from them. Words wrap whole, and the line keeps its direction on a right-to-left page. The letters rock by a few degrees, so the word stays readable at every moment, hovered too. With reduced motion the letters are still and upright.
FAQ
Why does hovering make it wobble harder, not faster?
A faster wobble would make every letter jump to a new point in its swing the moment the pointer arrives. Growing the wobble instead keeps each letter exactly where it was in its swing, so it builds smoothly and settles back the same way.
How does the wobble grow smoothly?
Both animations are scaled by --wobble-text-strength, a CSS custom property the install registers as a number. A registered property can be transitioned, so on hover it eases from 1 to 1.8 over half a second, and the letters follow it.
How is it different from Wave Text?
Wobble Text rocks each letter in place, with a soft swell, like jelly. Wave Text moves the letters up and down along a wave that rolls through the line.
What happens on a touch screen?
It wobbles at its usual size. Growing on hover only happens on devices with a pointer that can hover, so a tap doesn't leave it stuck at full wobble.
API Reference
WobbleText
<span> data-slot="wobble-text"
textstring
The text. Its line breaks (\n) are kept.
duration?number
One wobble of a letter, there and back, in milliseconds. @default 800.
hover?boolean
Whether the wobble grows while the pointer is over the text, or a link or button around it has keyboard focus.
- Default
true
intensity?"subtle" | "medium" | "strong"
How far each letter rocks and squishes. @default "medium".
- Type
"subtle" | "medium" | "strong"
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.
--wobble-text-anglestring
A letter's furthest rock either way (5deg).
--wobble-text-durationstring
One wobble, there and back (800ms).
--wobble-text-squishstring
How much a letter swells and shrinks (0.04).
--wobble-text-strengthstring
The wobble's multiplier: 1 at rest, 1.8 hovered.
Related
- Pro
Wave Text
MotionLetters riding a wave across the line
- Pro
Stretch Text
MotionLetters that squash flat and spring up
- Pro
Pendulum Text
InteractiveLetters that swing on strings
- Pro
Gloss Text
DecorativeGlossy letters like hard candy
- Pro
Bouncing Text
MotionLetters that bounce to celebrate
- Pro
Liquid Text
InteractiveLetters that melt into each other