Starfield

A canvas of stars. Near stars drift faster and lean further from the pointer, each twinkles on its own beat, and it follows the text color. Effects.

Open playground

About

Starfield is a React component in the Effects category of smoui. It is typed, ships no stylesheet, follows your theme through CSS variables, and honors prefers-reduced-motion. Import it with import { Starfield } from "@ashutoshswamy/smoui" and set count, speed, parallax among its 4 props.

Install

Terminal
npm i @ashutoshswamy/smoui

Usage

TSX
import { Starfield } from "@ashutoshswamy/smoui";

<div style={{ color: "white", background: "#0b0d14" }}>
  <Starfield height={320} count={160} />
</div>

Props 4

count

Number of stars.

numberdefault 140
speed

Drift multiplier. 0 keeps only the twinkle.

numberdefault 1
parallax

How far the field leans from the pointer, in px.

numberdefault 24
height

Height of the canvas.

numberstringdefault 280