← All components
Text Reveal
TextWord-by-word text reveal — tokens rise and fade in sequence as the line enters view.
Installation
One command drops the source into your repo — editable, with the provider and motion pulled in automatically.
npx shadcn add https://motion.asmitsah.dev/r/text-reveal.jsonPrerequisiteInstall the provider base first
This component imports from @/lib/motion and needs <MotionProvider> mounted in your root layout — install the base once, before copying this component.
npx shadcn add https://motion.asmitsah.dev/r/provider.jsonStep 1Install the runtime dependency
npm install motionStep 2Copy the source into
components/motion/text-reveal.tsxcomponents/motion/text-reveal.tsx
Usage
By word (default)
Wrap your own element — its tag + className win. Each word rises + fades 0.04s apart; the string stays one accessible label.
By char
Finer-grained — good for short headlines or a single emphasized line.
Trigger on mount
Play immediately instead of waiting for scroll — for above-the-fold hero text.
Custom stagger + delay
Slow the step down and lead with a delay to sequence against a neighboring element.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| children | ReactElement | — | A single host element (h1–h6/p/span/div) wrapping plain-string text. Its tag, className + style are reused and it carries the aria-label. Required. |
| by | "word" | "char" | "word" | Split granularity — stagger each word, or each character within each word. |
| trigger | "inView" | "mount" | "inView" | Animate on scroll-into-view (once) or immediately on mount. |
| stagger | number | 0.04 word / 0.02 char | Seconds between each staggered word/char. Overrides the by-based default. |
| delay | number | 0 | Seconds before the first word/char animates. |