Text typed character by character with a blinking caret.
Installation
Install the packages
npm install @prequelui/react motion@prequelui/react reuses the primitive library your components already depend on.
Add the component
npx shadcn@latest add https://animate.prequelui.terravidhal.me/r/typing-text.jsonnpx shadcn@latest add https://animate.prequelui.terravidhal.me/r/typing-text.json
Turn on the motion
npx @prequelui/cli@latest animate typing-textThe CLI finds the component through components.json, swaps the import and removes the CSS animation classes that Motion replaces.
Usage
Import the component and compose it exactly like the primitive it wraps. Motion is enabled by default; the tempo prop scales every duration and softens every spring.
import { TypingText, TypingTextCursor } from "@/components/prequelui/typing-text";
export default function Demo() {
return (
<p className="text-2xl font-medium">
<TypingText
text="Motion that feels right."
duration={100}
holdDelay={1000}
loop
>
<TypingTextCursor />
</TypingText>
</p>
);
}import { TypingText } from "@/components/prequelui/typing-text";
export function Variant() {
return (
<TypingText tempo={1.2}>
…
</TypingText>
);
}Animation
The text is written into the DOM one character at a time, held, then erased at a faster rate before the next string begins. The caret is a separate part: it stays solid while typing and blinks while the text is idle.
- Typing: 100 ms per character by default; erasing: 55 ms.
- Hold delay: 1 s, doubled as the pause between strings when looping.
- Caret blink: 1 s linear with a square duty cycle.
- Reduced motion writes the full string immediately with no blink.
API Reference
Each part accepts the usual HTML props in addition to the motion props below. No accessibility prop is hidden behind the animation layer.
TypingText
| Prop | Type | Default |
|---|---|---|
| text | string | string[] | — |
| duration | number | 100 |
| delay | number | 0 |
| holdDelay | number | 1000 |
| loop | boolean | false |
| inView | boolean | false |
TypingTextCursor
| Prop | Type | Default |
|---|---|---|
| className | string | — |