Skip to main content

Examples

Default

Fake Placeholder

Sized To Current

Inside A Button

Inside A Status Row

Props

CyclingText

Cycles through a list of strings with a slide-in/slide-out animation. Lives inline so it can sit inside divs, spans, buttons, or as a fake placeholder overlay.
readonly string[]
required
Strings to cycle through, in order. Cycles back to the first after the last.
boolean
default:"false"
When true, updates are exposed to assistive technologies via aria-live="polite". Leave false for decorative or frequently changing copy so screen readers are not interrupted on every cycle.
"up" | "down"
default:"up"
Direction the outgoing item slides.
number
default:"2100"
Milliseconds to wait after the previous transition finishes before starting the next one.
string
Class applied to each visible label span (current + incoming). Use this for effects that have to sit on the text element itself, e.g. background-clip: text.
((index: number) => void)
Called with the index of the settled, fully-visible item — once on mount and again whenever it changes (after each transition completes). Lets a parent stay in lockstep with what is on screen (e.g. to act on the item the user is currently looking at) without running a second, drifting timer of its own.
boolean
default:"false"
When true, freezes on the current item — no further cycling until cleared.
"longest" | "current"
default:"longest"
How the wrapper sizes itself horizontally.
  • longest reserves space for the longest item — no width jitter as items cycle.
  • current shrinks/grows with each item, animating width between cycles.
number
default:"200"
Slide and cross-fade duration in milliseconds.

Exported types

Also exported from @fanvue/ui: CyclingTextProps, CyclingTextSizing.
Setup: Installation · Theming