Letters roll over themselves like a split-flap board.
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/rolling-text.jsonnpx shadcn@latest add https://animate.prequelui.terravidhal.me/r/rolling-text.json
Turn on the motion
npx @prequelui/cli@latest animate rolling-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 { RollingText } from "@/components/prequelui/rolling-text";
export default function Demo() {
return (
<RollingText
text="MOVE WITH PURPOSE"
className="text-4xl font-semibold tracking-[0.06em]"
/>
);
}import { RollingText } from "@/components/prequelui/rolling-text";
export function Variant() {
return (
<RollingText tempo={1.2}>
…
</RollingText>
);
}Animation
Every character is a split-flap. The front face rotates away from its top edge while the back face falls into place from its bottom edge, character by character with a tenth of a second between them.
- Character tween: 500 ms ease-out with a 100 ms step.
- The back face starts 300 ms after its front face.
- Perspective is pushed very far to keep the glyphs the same size.
- The full string is exposed to assistive technology as one label.
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.
RollingText
| Prop | Type | Default |
|---|---|---|
| text | string | — |
| delay | number | 0 |
| inView | boolean | false |
| inViewOnce | boolean | true |
| transition | Transition | component spring or tween |