Stars pulled and pushed by an interactive gravity well.
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/gravity-stars.jsonnpx shadcn@latest add https://animate.prequelui.terravidhal.me/r/gravity-stars.json
Turn on the motion
npx @prequelui/cli@latest animate gravity-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 { GravityStarsBackground } from "@/components/prequelui/backgrounds/gravity-stars";
export default function Demo() {
return (
<div className="relative h-96 overflow-hidden rounded-xl">
<GravityStarsBackground gravity="attract" />
</div>
);
}import { GravityStars } from "@/components/prequelui/gravity-stars";
export function Variant() {
return (
<GravityStars tempo={1.2}>
…
</GravityStars>
);
}Animation
Eighty stars drift with a little noise and wrap around the edges. Inside a 110 px radius the pointer bends their velocity, brightens them and grows their glow; leaving the radius lets the same values settle back instead of resetting.
- Influence radius: 110 px; strength: 80; mode attract or repel.
- Glow follows the pointer distance and relaxes by 6% per frame.
- Stars are culled per frame and wrapped, never recreated on move.
- Reduced motion draws a still field with no velocity or glow.
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.
GravityStarsBackground
| Prop | Type | Default |
|---|---|---|
| interactive | boolean | true |
| starsCount | number | 80 |
| starsSize | number | 2 |
| starsOpacity | number | 0.75 |
| mouseInfluence | number | 110 |
| gravityStrength | number | 80 |
| gravity | "attract" | "repel" | "attract" |
| glowIntensity | number | 14 |
| starColor | string | "#f8fafc" |
| speed | number | 1 |
| paused | boolean | false |
| className | string | — |