Skip to content
IndexRequest a UIAboutContact

Rotating Text Swap

A headline word that slides up and is replaced by the next, with a pause control.

Open alone ↗

AI prompt

PROMPT: PASTE INTO YOUR AI CODING TOOL
Create the headline "Design with" followed by a rotating word slot cycling through "clarity", "motion", "feeling" and "intent", in 26px semibold. The slot is an inline-block with overflow hidden, a fixed width equal to the longest word and a height of one line. Every 2200ms the current word animates translateY(0) to translateY(-100%) with opacity to 0 while the next word animates from translateY(100%) to 0, over 420ms cubic-bezier(.3,.8,.2,1). Add a small Pause button that toggles to Play, and also pause while the pointer is over the headline or any element inside has focus. The visible animated words have aria-hidden and a visually hidden span reads "Design with clarity, motion, feeling and intent" once. Under prefers-reduced-motion start paused and swap words without movement when the user presses Play.

About this pattern

Definition

One word in a sentence changes on a timer. The old word slides up and fades while the new one rises from below, keeping the sentence stable around it.

Purpose & UX principles

  • Shows several benefits in one line without extra space.
  • Automatically moving text must be pausable (WCAG 2.2.2): there is a pause button, and it also pauses while hovered or focused.
  • The sentence is readable without the animation: the live region is off and a full list of the words is available to screen readers once.

Interaction states

  • Playing, paused (button shows Play), hover-paused, focus-visible on the button.

Motion specification

  • Each swap: old word translateY 0 to -100% and opacity to 0, new word from +100%; 420ms cubic-bezier(.3,.8,.2,1). A new word every 2200ms.
  • Reduced motion: the rotation starts paused and swaps without movement when the button is pressed.

Responsive behaviour

  • The word slot has a fixed width equal to the longest word so surrounding text does not jump.
  • Font size scales with the container.

Code

HTML
<div class="hd"><h2 aria-label="Design with clarity, motion, feeling and intent"><span aria-hidden="true">Design with </span><span class="slot" id="slot" aria-hidden="true"><span class="w">clarity</span></span></h2>
<button id="pz" type="button">Pause</button></div>

Related patterns

Staggered Entrance

↗
Staggered EntranceMotion & Transitions

Easing Comparison

↗
Easing ComparisonMotion & Transitions

Rolling Counter

↗
Rolling CounterMicro Interactions