Starfield
Parallax stars with a hyperspace warp.
Far from everything
Holding at Kepler-442
Installation
npx shadcn@latest add https://neonkit.heyaadi.com/r/starfield.jsonUsage
import { Starfield } from "@/components/ui/starfield"
<section className="relative overflow-hidden bg-[#05060a]">
<Starfield />
<h1 className="relative">Far from everything</h1>
</section>Examples
Warp as a loading state
Tie warp to a long-running task. Here it runs while a deploy rolls through regions, and the status line is a polite live region.
Layered with Aurora
Background layers stack. Put the stars first and the aurora over them.
Density, tint and speed
API reference
A canvas that fills its nearest positioned parent. Accepts native div attributes.
| Prop | Type | Default |
|---|---|---|
color | NeonColorTint for some of the stars and for the warp streaks. | inherited |
warp | booleanHyperspace. The jump spools up over about a second, and dropping out eases back to cruising. | false |
density | numberStars per 10,000 square pixels, capped at 1,400 stars. | 7 |
speed | numberCruising speed toward the viewer. 0 holds still. | 1 |
parallax | numberPixels the nearest stars shift toward the pointer. 0 turns it off. | 24 |
tint | numberShare of stars that take the neon color, 0 to 1. | 0.18 |
twinkle | booleanSmall stars shimmer. | true |
Accessibility
- Decorative: rendered with aria-hidden and pointer-events: none. If warp means something (like a loading state), say so in text as well; the deploy example uses a live region.
- The canvas sizes itself with a ResizeObserver, caps the pixel ratio at 2, and stops drawing when it scrolls offscreen or the tab is hidden.
- Under prefers-reduced-motion it draws one still frame: no drift, no parallax and no warp.
- It reads --neon from the page, so a color set on an ancestor (or the accent picker) re-tints it live.