Text Effect
Animated text for a hero line or a status: rotating words, a typewriter, a scramble, a shimmer or a staggered reveal.
c2-text-effect animates a word or a line in place. Use it for a landing page’s hero (“Build faster”), a typed prompt suggestion, or an agent’s “Thinking…” status. Assistive technology reads the still text, and under reduced motion it shows the final state at once.
Import
import '@c2n/components/text-effect'Usage
Build
Effects
rotatecycles throughwords, each one sliding up and out. The element is as wide as the widest word, so the line never jumps;--c2-text-effect__rotate--alignplaces a narrower one.typewritertypes the text, or each ofwordsin turn, deleting one before typing the next. Withoutloopit stops on the last.scrambleresolves random characters into the text, left to right.shimmersweeps a light across the text, in a loop: a status that is still working.reveal(the default) fades and lifts the words into place, one after another.
words is a ;-separated list or a JSON array; without it, the effect animates the element’s own text.
When it plays
play="load" (the default) starts it when it appears, in-view the first time it scrolls into view, and hover each time the pointer or focus enters it (it rests on the full text in between). loop repeats an effect that otherwise plays once, replay() starts it again, and effect-end fires when a one-shot effect finishes. Nothing runs while it is off screen or the page is hidden.
Styling
Timings are variables: --c2-text-effect--interval (how long a word stays), --c2-text-effect__char--duration (typing and scramble speed), the shimmer’s duration and colours, and the reveal’s duration and stagger. A gradient fill works with any effect:
.brand {
--c2-text-effect__text--background: linear-gradient(90deg, #2563eb, #9333ea, #db2777);
--c2-text-effect__text--color: transparent;
}