# Morphing Text

> Rotates through a list of words, letters rising in and drifting out.

Category: Text · Free · Updated 2026-10-20 · Live demo: https://www.motionkitui.com/components/morphing-text

## When to use it

Rotating value propositions in a hero ("for designers / developers / teams") and other short lists of alternatives.

## How it works

A timer moves to the next word every interval. AnimatePresence in popLayout mode lets the outgoing word's letters drift up and blur away while the new word's letters rise in one after another. With reduced motion on, the rotation never starts and the first word stays.

## Installation

```bash
npx shadcn@latest add https://www.motionkitui.com/r/morphing-text.json
```

Or copy `components/motionkit/morphing-text.tsx` below. Requires react, motion and Tailwind CSS v4. Free for personal projects; commercial use needs MotionKit Plus (https://www.motionkitui.com/pricing).

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `words` | `string[]` |  | Words to rotate through. |
| `interval` | `number` | `2.4` | Seconds each word stays. |
| `stagger` | `number` | `0.03` | Seconds between letters as a word arrives. |

## Accessibility

- **Keyboard: Not applicable.** Text only, nothing to focus.
- **Screen readers: Pass.** Screen readers hear the full list once ("web, mobile, teams") instead of a word that keeps changing.
- **Reduced motion: Partial.** Reduced-motion users see the first word, with no rotation. It loops forever otherwise, so if it sits beside other content for more than 5 seconds, WCAG 2.2.2 asks you to add a pause control.
- **Colour contrast: Not applicable.** Uses whatever text colour you pass in className.

## Source

```tsx
"use client";

import { useEffect, useState } from "react";
import { AnimatePresence, motion, useReducedMotion } from "motion/react";

type MorphingTextProps = {
  words: string[];
  /** Seconds each word stays before the next arrives. */
  interval?: number;
  /** Seconds between letters as a word arrives. */
  stagger?: number;
  className?: string;
};

export function MorphingText({ words, interval = 2.4, stagger = 0.03, className = "" }: MorphingTextProps) {
  const reduceMotion = useReducedMotion();
  const [index, setIndex] = useState(0);

  useEffect(() => {
    // rotating text never starts for reduced-motion users: they see the first word
    if (reduceMotion || words.length < 2) return;
    const timer = window.setInterval(() => setIndex((current) => (current + 1) % words.length), interval * 1000);
    return () => window.clearInterval(timer);
  }, [reduceMotion, words.length, interval]);

  const word = words[reduceMotion ? 0 : index % words.length] ?? "";

  return (
    <span className={`relative inline-flex ${className}`}>
      <span className="sr-only">{words.join(", ")}</span>
      <AnimatePresence mode="popLayout" initial={false}>
        <motion.span key={word} aria-hidden className="inline-flex whitespace-pre">
          {word.split("").map((letter, letterIndex) => (
            <motion.span
              key={letterIndex}
              className="inline-block"
              initial={{ opacity: 0, y: "0.4em", filter: "blur(6px)" }}
              animate={{ opacity: 1, y: 0, filter: "blur(0px)" }}
              exit={{ opacity: 0, y: "-0.4em", filter: "blur(6px)", transition: { duration: 0.2, delay: letterIndex * stagger * 0.5 } }}
              transition={{ duration: 0.35, delay: letterIndex * stagger, ease: [0.22, 1, 0.36, 1] }}
            >
              {letter}
            </motion.span>
          ))}
        </motion.span>
      </AnimatePresence>
    </span>
  );
}
```
