Skip to content
English
Word rotate comes with Pro. Its preview shows once you unlock it.

How it works

The root is a one-cell inline-grid and every candidate word stays in the DOM, stacked in that cell: the width is the widest word and the baseline comes from the first, so surrounding text never moves and a long word cannot wrap the line. Enter and exit are CSS keyframes (translateY 0.5em, fade, blur), not transitions, so each always starts from the right side. JS only restarts a timeout after each switch, so a resume waits a full interval; it stops when the page is hidden.

Use it for

  • A hero headline that rotates selling points: “Shopping made [safe / simple / fast]”.
  • A sentence where only one item changes, such as a list of supported cities.
  • A slogan on a sign-in or empty page that needs some motion without moving the whole line.

Look elsewhere when

  • Words of very different lengths: the short ones leave a large gap; switch whole sentences or rewrite.
  • Information people must see in full, such as prices, rules or risks: rotating text disappears.
  • Body paragraphs, or several on one screen: constant motion disturbs reading.
  • A letter-by-letter reveal: use a typewriter effect.

Usage

import { WordRotate } from './WordRotate.jsx'

export function Hero() {
  return (
    <h1>
      Shopping made{' '}
      <WordRotate words={['safe', 'simple', 'fast']} interval={2200} style={{ color: 'var(--ds-accent, #2563eb)' }} />
    </h1>
  )
}

// A word in the middle of a sentence reads better centered
<p>
  Every day <WordRotate words={['3,200', '12,800', '860']} align="center" direction="down" /> people find what they need here
</p>

Props

PropTypeDefaultWhat it does
wordsstring[]—The words to rotate through, in a loop. With one word nothing rotates. Changing the list returns to the first word.
intervalnumber2200How long each word stays, in ms. Never shorter than the enter duration + 240ms.
durationnumber360Slide-in duration in ms; the old word leaves in 0.7 times that. Follows --ds-duration-slow if omitted.
direction'up' | 'down''up'up: the old word slides up and the new one comes from below; down is the reverse.
align'start' | 'center' | 'end''start'Alignment of a word narrower than the reserved width (the widest word). Use start at the end of a sentence and center in the middle.
blurbooleantrueAdds a slight 6px blur while entering and leaving.
pauseOnHoverbooleanfalsePauses rotation while a mouse pointer is over it.
pausedbooleanfalsePauses from outside.
labelstringall words joinedText read by screen readers. By default all words joined with a comma.
labelsobject—Replaces built-in text (separator, separatorCjk): the strings used to join the words in the screen-reader text. Shallow-merged over the defaults.
onChange(index: number) => void—Called when a new word is shown.
as'span' | 'strong' | 'em' | 'b' | 'i' | 'mark''span'Which inline tag to render.
...restHTMLAttributes—Other attributes go to the root element, such as className and style (often used to color the rotating word).

Accessibility

  • The rotating layer is aria-hidden; a fixed hidden text lists all the words joined with a comma (“safe, simple, fast”), so screen readers hear them once and the content never changes.
  • No aria-live: interrupting a screen reader every two seconds is worse than silence. Use label to read something else.
  • The hidden words and screen-reader text are not selectable, so copying the sentence gives only the visible word.
  • Reduced motion removes the movement and blur and only cross-fades; pass paused to hold it completely still.
  • pauseOnHover and paused let people stop it, and it stops when the page is hidden.

Motion

New word: translateY 0.5em, fade in and blur 6px to 0, 360ms ease-out, starting 54ms late. Old word: opposite 0.5em and fade out in 252ms ease-in. Each word stays 2200ms.

Add it to your project

Pro members copy a prompt and their coding agent installs the source, the same way as the free components.

WordRotate.jsxword-rotate.csstokens.cssREADME.md

Both files install together. The stylesheet reads the design tokens in tokens.css and carries fallbacks, so it also works alone.

Text motion
Morphing text comes with Pro. Its preview shows once you unlock it.