Command Palette

Search for a command to run...

Components
Previous

Stars Travel

A motion-driven SVG background with an animated 'infinite travel' effect.

Loading...
import { StarsTravel } from "@/components/stars-travel";
 
export default function StarsTravelDemo() {
  return (
    <div className="relative flex min-h-72 w-full flex-col items-center justify-center overflow-hidden">
      <StarsTravel className="pointer-events-none absolute inset-0" />
      <h1 className="relative z-10 max-w-70 text-center text-3xl text-foreground max-sm:max-w-60 max-sm:text-2xl">
        Space travel looks better in code
      </h1>
    </div>
  );
}

Installation

bunx --bun shadcn@latest add "https://www.kushaj.in/r/stars-travel.json"

Usage

import { StarsTravel } from "@/components/stars-travel";
<StarsTravel>
  <div className="relative z-10 flex h-full items-center justify-center text-white">
    Your content goes here
  </div>
</StarsTravel>

Examples

Custom Animation Speed

Adjust the duration to make the travel effect faster or slower.

Loading...
import { StarsTravel } from "@/components/stars-travel";
 
export default function StarsTravelDurationDemo() {
  return (
    <div className="relative flex min-h-72 w-full flex-col items-center justify-center overflow-hidden">
      <StarsTravel
        className="pointer-events-none absolute inset-0"
        svgOptions={{ duration: 1 }}
      />
      <h1 className="relative z-10 max-w-70 text-center text-3xl text-foreground max-sm:max-w-60 max-sm:text-2xl">
        Space travel looks better in code
      </h1>
    </div>
  );
}

API Reference

PropTypeDefaultDescription
childrenReactNode-Content layered over the animated stars-travel.
classNamestring-Classes for the stars-travel container.
svgOptionsobject{}Animated stars-travel settings.
svgOptions.durationnumber2Loop duration in seconds.