# Word Rotate

> Rotates 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.

- Kind: Motion component (Motion)
- Docs: https://ui.minidev.pro/docs/word-rotate
- Source (registry JSON with the full file): https://ui.minidev.pro/r/word-rotate.json
- License: MIT. One file, yours to edit after install.

## 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.

## Installation

### shadcn CLI (copies the source into your project)

```bash
npx shadcn@latest add @minidev/word-rotate
```

Writes `components/ui/word-rotate.tsx` and installs its npm dependencies. Older CLI versions: `npx shadcn@latest add https://ui.minidev.pro/r/word-rotate.json`.

### npm package

```bash
npm i minidev-ui-kit motion
```

Add the tokens to your global stylesheet once:

```css
@import "tailwindcss";
@import "minidev-ui-kit/styles.css";
@source "../node_modules/minidev-ui-kit";
```

Next.js also needs `transpilePackages: ["minidev-ui-kit"]` in next.config.

## Import

After the shadcn install:

```tsx
import { WordRotate } from "@/components/ui/word-rotate"
```

From the npm package:

```tsx
import { WordRotate } from "minidev-ui-kit/premium/word-rotate"
```

## Usage

```tsx
import { WordRotate } from "@/components/ui/word-rotate"

export function Example() {
  return (
    <WordRotate />
  )
}
```

## Props

| Prop | Type | Default | Required | Description |
| --- | --- | --- | --- | --- |
| `words` | `string[]` | `["startups", "agencies", "fintech", "...` | no | Words to cycle through, in order. |
| `interval` | `number` | `2200` | no | Milliseconds each word stays. |
| `className` | `string` | - | no |  |
| `prefix` | `React.ReactNode` | `"Interfaces for"` | no | Text before the rotating word. |

## Examples

### Custom words

Pass words and a prefix; the slot keeps the width of the longest word so nothing jumps.

```tsx
<WordRotate prefix="Invoices for" words={["agencies", "consultants", "studios", "freelancers"]} />
```

### Faster interval

interval is the time each word stays in milliseconds; keep it above a second for reading.

```tsx
<WordRotate prefix="Paid in" words={["USD", "EUR", "GBP", "INR", "BRL"]} interval={1200} />
```

### Inside a headline

Size it with className and drop the prefix to use the slot in the middle of your own sentence.

```tsx
<h2 className="max-w-md text-center text-2xl font-medium tracking-[-0.03em] text-fg sm:text-3xl">
  Lumen gets your <WordRotate prefix={null} words={["invoices", "reminders", "receipts", "statements"]} className="text-2xl sm:text-3xl" /> out the door
</h2>
```

## Accessibility

- The full word list is in an `sr-only` span and the animated slot is `aria-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.

## FAQ

### 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.

## Rules for generating code

- Use semantic tokens only (bg, surface, sunken, border, fg, fg-muted, fg-subtle, ink, accent, success, warning, danger). Never raw hex or palette steps like blue-500.
- Shadows only from the set: shadow-xs, shadow-sm, shadow-raised, shadow-md, shadow-lg, shadow-overlay.
- Numbers use tabular-nums. Dark mode is the `dark` class on <html>; components never branch on theme.

## Dependencies

- npm: `motion`

## Related

- [Morphing Text](https://ui.minidev.pro/docs/morphing-text/md): React headline that cycles through phrases by blurring one into the next on two stacked layers, pauses off screen and shows the first phrase for reduced motion.
- [Typing Text](https://ui.minidev.pro/docs/typing-text/md): A React typewriter that types a phrase, holds, deletes and moves on, with a blinking accent caret. Starts in view and gives screen readers the plain text.
- [Hyper Text](https://ui.minidev.pro/docs/hyper-text/md): A React text effect that scrambles characters through random glyphs and settles them left to right on mount or hover, in monospace so the width never jumps.
- [Text Scramble](https://ui.minidev.pro/docs/text-scramble/md): A text effect that scrambles random glyphs and resolves to the final string letter by letter when it scrolls into view. Its aria-label keeps the real text.
- [Animated Feature Row](https://ui.minidev.pro/docs/animated-feature-row/md): A row of feature cards that slide up with a staggered delay when scrolled into view. Pass title and description pairs; reduced motion keeps them still.
- [Card Tilt](https://ui.minidev.pro/docs/card-tilt/md): A card that tilts in 3D toward the pointer on springs, with an accent glare that follows the cursor. It stays flat when reduced motion is preferred.

---

All 557 components: https://ui.minidev.pro/llms.txt (full text: https://ui.minidev.pro/llms-full.txt).
