A marker highlight that draws in behind the words.
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/highlight-text.jsonnpx shadcn@latest add https://animate.prequelui.terravidhal.me/r/highlight-text.json
Turn on the motion
npx @prequelui/cli@latest animate highlight-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 { HighlightText } from "@/components/prequelui/highlight-text";
export default function Demo() {
return (
<p className="text-2xl">
Motion should feel{" "}
<HighlightText text="inevitable" delay={250} />.
</p>
);
}import { HighlightText } from "@/components/prequelui/highlight-text";
export function Variant() {
return (
<HighlightText tempo={1.2}>
…
</HighlightText>
);
}Animation
The highlight is a background block clipped to the text box. It grows from zero width to full width behind the words, from the left, in two seconds; there is no separate element to misalign.
- Background size: 0% 100% → 100% 100% over 2 s ease-in-out.
- Delay is expressed in milliseconds and added to the transition delay.
- The text never moves; only its background box changes size.
- Reduced motion shows the final highlight immediately.
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.
HighlightText
| Prop | Type | Default |
|---|---|---|
| text | string | — |
| delay | number | 0 |
| color | string | soft amber |
| inView | boolean | false |
| inViewOnce | boolean | true |