Text slides out of its box while a copy slides in.
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/sliding-text.jsonnpx shadcn@latest add https://animate.prequelui.terravidhal.me/r/sliding-text.json
Turn on the motion
npx @prequelui/cli@latest animate sliding-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 { SlidingText } from "@/components/prequelui/sliding-text";
export default function Demo() {
return (
<button className="rounded-lg bg-accent px-5 py-2 text-[15px] font-medium">
<SlidingText text="Read the story" />
</button>
);
}import { SlidingText } from "@/components/prequelui/sliding-text";
export function Variant() {
return (
<SlidingText tempo={1.2}>
…
</SlidingText>
);
}Animation
The label and an identical copy sit in a clipped box. Hovering slides both by exactly one line plus a 0.6 em gap, so the copy lands where the original was; the motion is a single continuous value that can be interrupted at any time.
- Slide: 250 ms with a fill curve, on a retargetable motion value.
- Gap between the two copies: 0.6 em; bleed: 0.25 em.
- Inside a link or a button, the whole host drives the slide.
- Reduced motion jumps between the two positions.
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.
SlidingText
| Prop | Type | Default |
|---|---|---|
| text | string | — |
| direction | "up" | "down" | "down" |
| trigger | "hover" | "click" | "hover" |
| transition | Transition | component spring or tween |