GooseUI

Components

Rotating Text

New

A word inside a sentence that changes on a timer. Letters flip in around the X axis out of a blur, one after another, and leave the same way mirrored. It is a server component with no JavaScript: one registered custom property runs from 0 to 1 over the whole cycle, and every letter computes its opacity, rotation and blur from it with clamp(). The surrounding text does not jump: all words share one grid cell, so the component either reserves room for the longest word or tweens its width. Screen readers hear one static variant instead of every change.

Browser Support

Registered custom properties

Drives the word rotation cycle.

Your browser:

Preview

Build websites
that people enjoy

Installation

npx shadcn@latest add @gooseui/rotating-text
pnpm dlx shadcn@latest add @gooseui/rotating-text
yarn dlx shadcn@latest add @gooseui/rotating-text
bunx --bun shadcn@latest add @gooseui/rotating-text

Usage

import { RotatingText } from "@/components/ui/rotating-text"

export default function Hero() {
  return (
    <h1 className="text-4xl font-semibold">
      Build{" "}
      <RotatingText
        words={["websites", "apps", "dashboards", "stores"]}
        className="text-primary"
      />{" "}
      that people enjoy
    </h1>
  )
}

Examples

Animated width

With widthMode="animate" the gap around the word follows its length instead of staying at the longest one.

Build websites that people enjoy

<RotatingText words={words} widthMode="animate" />

Status line

A slower stagger and a heavier blur suit a loading or status label.

LOADING
<RotatingText
  words={["LOADING", "SEARCHING", "SORTING", "DONE"]}
  interval={2000}
  stagger={0.08}
  blur={10}
  duration={0.6}
  className="text-4xl font-bold tracking-widest"
/>

Screen reader label

By default assistive tech reads the first word. Pass srLabel when a summary reads better.

<RotatingText
  words={["websites", "apps", "dashboards"]}
  srLabel="websites, apps and dashboards"
/>

Props

PropTypeDefaultDescription
wordsstring[]-Words to cycle through
intervalnumber2500How long each word stays, in ms
widthMode"reserve" | "animate""reserve"reserve keeps the width of the longest word, animate tweens the width to the current one
durationnumber0.5Duration of one letter animation, in seconds
staggernumber0.04Delay between letters, in seconds
blurnumber6Blur of an entering or leaving letter, in px
srLabelstringwords[0]Static text for screen readers. The first word by default
classNamestring-Additional CSS classes