Word Rotate
MotionRotates words inside a sentence: the old word lifts and blurs away as the next rises in. The slot keeps the widest word's width so the line never jumps.
Installation
npx shadcn@latest add @minidev/word-rotate
MiniDev UI is in the shadcn registry directory, so the short form works with no setup. Older CLI versions can use the full URL: npx shadcn@latest add https://ui.minidev.pro/r/word-rotate.json
Usage
import { WordRotate } from "@/components/ui/word-rotate"
export function Example() {
return (
<WordRotate />
)
}
API reference
When to use
Use it for a hero line like "Interfaces for <rotating word>". Reach for MorphingText to cycle whole phrases, TypingText for a typewriter, and HyperText or TextScramble for a one-off decode.
Accessibility
- The full word list is in an
sr-onlyspan and the animated slot isaria-hidden, so changes are never announced one by one. - It only rotates while half of it is in view.
- Under reduced motion it shows the first word and never changes.
Frequently asked questions
Will the rotating word make the sentence jump?
No. Every word is rendered invisibly in the same slot, so it is always as wide as the longest word. Long words in the list make a wide gap after short ones, so keep them a similar length.
Can I use WordRotate inside an h1?
Yes, it renders a <span>. Screen readers hear the prefix and then the full list, such as "Interfaces for startups, agencies, fintech", so the heading still makes sense.
Dependencies
npm
Built from
Examples
Custom words
Pass words and a prefix; the slot keeps the width of the longest word so nothing jumps.
Faster interval
interval is the time each word stays in milliseconds; keep it above a second for reading.
Inside a headline
Size it with className and drop the prefix to use the slot in the middle of your own sentence.