Components / Backgrounds
Starfield
Stars streaming toward you through space. Hover to jump to warp speed.
To infinity
Hover to jump to warp speed.
Installation
Requires React 18+ and Tailwind CSS.
- 1
Install dependencies
None. This component only needs React and Tailwind.
- 2
Add the component
Copy the code from the Code tab above into
components/ui/starfield.tsx. - 3
Use it
example.tsximport { Starfield } from "@/components/ui/starfield"; export default function StarfieldDemo() { return ( <Starfield className="h-72 w-full rounded-2xl border border-zinc-200 bg-white dark:border-white/10 dark:bg-zinc-950"> <div className="pointer-events-none flex h-full flex-col items-center justify-center text-center"> <h3 className="text-2xl font-semibold text-zinc-900 dark:text-white">To infinity</h3> <p className="mt-1 text-sm text-zinc-600 dark:text-zinc-400">Hover to jump to warp speed.</p> </div> </Starfield> ); }
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| count | number | 350 | Number of stars. |
| speed | number | 1 | Cruising speed multiplier. |
| warpOnHover | boolean | true | Speed up while hovered. |
| className | string | — | Star color comes from the text color. |