AnimationUpdated in v15

Rotating Text

Cycles through a list of words in one place.

Installation

Import the class, and @use the entry point in your global styles: without it the component renders unstyled.

import { Component } from '@angular/core';
import { WrRotatingText } from 'ngwr/bits/rotating-text';

@Component({ imports: [WrRotatingText] })
export class MyComponent {}
Angular adaptation of an effect by David Haz / reactbits.dev.

Playground

We design every day.
<wr-rotating-text
  [texts]="['design', 'ship', 'iterate']"
  [rotationInterval]="2000"
  splitBy="characters"
  [duration]="0.6"
  easing="cubic-bezier(0.16, 1, 0.3, 1)"
  [staggerDuration]="0"
  staggerFrom="first"
  [loop]="true"
/>

Customize

Interval (ms)
2000 ms
Split By
Duration (s)
0.60 s
Easing
Stagger (s)
0.00 s
Stagger From
Loop

API

NameDescriptionTypeDefault
textsrequiredStrings to cycle.readonly string[]—
rotationIntervalAuto-advance interval in ms.number2000
splitByGranularity of the split.'characters' | 'words' | 'lines''characters'
autoAuto-advance on a timer.booleantrue
loopLoop back to the first string after the last.booleantrue
durationPer-swap tween duration in seconds.number0.6
easingCSS easing of the per-piece tween.string'cubic-bezier(0.16, 1, 0.3, 1)'
staggerDurationPer-piece stagger in seconds.number0
staggerFromStagger origin.'first' | 'last' | 'center''first'
(nextChange)Emits with the new index on every rotation.number—
next() / previous() / jumpTo(i) / reset()Imperative methods on the component instance.method—

See also