Background

Stars

Three parallax star layers drifting at different speeds.

stars.tsx

Installation

1

Install the packages

npm install @prequelui/react motion

@prequelui/react reuses the primitive library your components already depend on.

2

Add the component

npx shadcn@latest add https://animate.prequelui.terravidhal.me/r/stars.json

npx shadcn@latest add https://animate.prequelui.terravidhal.me/r/stars.json

3

Turn on the motion

npx @prequelui/cli@latest animate stars

The 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.

stars.tsx
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.
50 / 100 / 150 s3 layersbox-shadow fieldparallax 50 / 20

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

PropTypeDefault
starColorstring"#f8fafc"
factornumber0.05
pointerEventsbooleantrue
speednumber1
pausedbooleanfalse
classNamestring—

Built by Vidhal. The source is available on GitHub.

Last updated: 11/17/2026