cnippet/ui
  1. motion
  2. text animations
  3. text loop

text animations

Text Loop

Cycles through an array of children with smooth enter and exit transitions, swapping content on a configurable interval.

Installation

Usage

Anatomy

Good to know

  • Each child is one item. Unlike RotatingText, the items can be any elements, not just strings.
  • interval is in seconds (default 2). trigger={false} pauses the loop.
  • onIndexChange reports which item is showing.
  • Screen readers only hear the item that's showing when they reach it.
  • When the user has turned on reduced motion, items still change on the interval but swap instantly, with no transition.

Props

Examples

Looping Adjectives

Inline within a heading, cycling benefit words in the brand color. Each child is a <span> but can be any ReactNode.

Animated Status Badge

Rich content items — icon + label — cycle inside a pill badge with a vertical slide transition. The variants prop drives direction.

Horizontal Slide

Custom variants swap the default fade+y for a horizontal slide, matching the direction to a left-to-right reading flow.