Three parallax star layers drifting at different speeds.
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/stars.jsonnpx shadcn@latest add https://animate.prequelui.terravidhal.me/r/stars.json
Turn on the motion
npx @prequelui/cli@latest animate starsThe 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 { StarsBackground } from "@/components/prequelui/backgrounds/stars";
export default function Demo() {
return (
<div className="relative h-96 overflow-hidden rounded-xl">
<StarsBackground />
</div>
);
}import { Stars } from "@/components/prequelui/stars";
export function Variant() {
return (
<Stars tempo={1.2}>
…
</Stars>
);
}Animation
Three layers of stars are painted as box shadows instead of nodes. Each layer falls at its own speed and repeats seamlessly; the pointer adds a small parallax offset on a soft spring.
- Layer multipliers: 1×, 2× and 3× the base speed; 50 s, 100 s and 150 s at speed 1.
- Stars are generated from a seeded distribution, so the field is stable between renders.
- Pointer parallax: stiffness 50, damping 20, factor 0.05.
- Reduced motion stops every layer and keeps the composed field.
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.
StarsBackground
| Prop | Type | Default |
|---|---|---|
| starColor | string | "#f8fafc" |
| factor | number | 0.05 |
| pointerEvents | boolean | true |
| speed | number | 1 |
| paused | boolean | false |
| className | string | — |