A living star network: points of light drifting through depth with parallax and bokeh, joined by delicate lines that form and dissolve, now and then drawing a named figure.

  • canvas
  • stars
  • constellation
  • network
  • particles
  • background
  • interactive
  • hero
Preset

Installation

pnpm dlx shadcn@latest add https://kagadmodyaa.vercel.app/r/constellation.json

Needs a React + Tailwind project set up with shadcn. Copies the effect into your project, along with lib/effect-runtime.ts, the small WebGL layer it runs on. No other dependencies.

Or from npm

pnpm add @kagadmodyaa/effects
import { Constellation } from '@kagadmodyaa/effects/constellation'

One package with every free effect, one import path each. No Tailwind or shadcn needed, and no stylesheet to import: the few layout rules an effect needs come with it. The npm package and the command above ship the same source.

Usage

Use it like any other component. Choose a theme with preset; any prop you pass as well overrides the preset.

import { Constellation } from '@/components/effects/constellation/constellation'

export function Hero() {
  return (
    <section className="relative h-[640px] overflow-hidden">
      {/* fills its parent; move the pointer over it, or click for a supernova */}
      <Constellation preset="Observatory" className="absolute inset-0" />
      <div className="relative z-10 mx-auto max-w-xl px-6 pt-28 text-center text-white">
        <h1 className="text-5xl font-semibold tracking-tight">Find the shape of the night.</h1>
      </div>
    </section>
  )
}

// Presets: Observatory, Aurum, Chart (the light one: ink on paper), Nebula, Mono.
// The stage above is <ConstellationShowcase />, also exported, with a headline and a button that calls
// ref.current.nova() to set off a supernova. figureRegion=[left, top, right, bottom] keeps figures clear of your copy.
<Constellation preset="Aurum" count={220} />

Presets

  • Observatory
  • Aurum
  • Chart
  • Nebula
  • Mono

Props

NameTypeDefaultDescription
preset'Observatory' | 'Aurum' | 'Chart' | 'Nebula' | 'Mono'none (the defaults below)A named theme. Any prop you pass as well overrides the preset’s value.
countnumber220Stars on a 1200 by 720 stage. The count scales with the size of the stage and backs off on slow devices. Range 60 to 600.
starSizenumber1Size of the stars. Brighter and nearer stars are larger. Range 0.4 to 2.5.
twinklenumber0.55How much the stars shimmer, with now and then a brief glint. Range 0 to 1.
spreadnumber0.7How much star colours vary with temperature, from cool to hot. 0 is a single colour. Range 0 to 1.
linkDistancenumber135How far a star reaches for a neighbour. Near stars reach further, far ones less. Range 40 to 260 px.
linkOpacitynumber0.55Strength of the lines between stars. Range 0 to 1.
linkWidthnumber1Width of the lines, as a multiple of a hairline. Range 0.4 to 2.2.
figuresbooleantrueNow and then a handful of stars glide into a named figure and are joined by crisp lines.
depthnumber0.65Parallax between the layers: how far the camera drifts and leans with the pointer. 0 is a flat sky. Range 0 to 1.
bokehnumber0.55Depth of field. Stars in front of and behind the focus layer melt into soft discs. Range 0 to 1.
nebulanumber0.6Two layers of drifting cloud behind the stars. Range 0 to 1.
speednumber1How fast the sky drifts and the figures come and go. 0 freezes it. Range 0 to 3.
pointerRadiusnumber0.22Size of the pointer's lantern, as a fraction of the stage's shorter side. Range 0.05 to 0.5.
pointerForcenumber1How strongly the pointer pulls and lights the stars and how hard a click bursts. 0 turns it off. Range 0 to 2.
pointerLinksbooleantrueJoin the stars near the pointer to it with fine lines.
starColorstring'#e4eeff'Ordinary stars. A hex colour.
warmColorstring'#ffd9b4'The hot end of the spectrum. A hex colour.
coolColorstring'#93b6ff'The cool end of the spectrum. A hex colour.
linkColorstring'#8fb0ff'The lines between stars. A hex colour.
backgroundstring'#050a17'Background colour. A light colour switches the sky to a chart: ink dots and hairlines on paper. A hex colour.
hazeAstring'#1d3f9a'Broad, soft cloud. A hex colour.
hazeBstring'#0f7c97'Finer, wispier cloud. A hex colour.
gridnumber0A faint chart grid of circles, meridians and a degree scale. Range 0 to 1.
grainnumber0.3Film grain. A little is always on to keep the dark gradients smooth. Range 0 to 1.
classNamestring—Extra class on the root element. The effect fills its parent: give the parent a height.
styleCSSProperties—Inline style on the root element.

Files

What the command adds to your project, and where.

  • components/effects/constellation/constellation.tsx

    The component.

  • components/effects/constellation/network.tsx

    The component.

  • components/effects/constellation/showcase.tsx

    The component.

  • components/effects/constellation/poster.tsx

    The component.

  • components/effects/constellation/engine.ts

    The component.

  • components/effects/constellation/sprites.ts

    The component.

  • components/effects/constellation/loop.ts

    The component.

  • components/effects/constellation/look.ts

    The component.

  • components/effects/constellation/figures.ts

    The component.

  • lib/effect-runtime.ts

    Shared by every shader effect: resizing, pausing, reduced motion, context loss and the no-WebGL fallback. Installed once.

Behaviour

  • Stars drift slowly on layers: near ones slide further than far ones as the camera wanders, and the pointer leans it a little. Depth also sets size and brightness, and a focus plane sits in the middle, so stars in front of and behind it become soft bokeh discs. Set depth to 0 for a flat sky.
  • Each star links to its few nearest neighbours on the same layer. Lines fade with distance, depth and focus, and they grow in and dissolve out smoothly as stars drift together and apart, so the network is always rewiring.
  • Every so often a handful of stars glide into a named figure: crisp lines are drawn between them, they flare with diffraction spikes and the name appears, then everything lets go and drifts on. Turn constellation figures off to keep it a pure drifting network.
  • Move the pointer over the page and it becomes a lantern: nearby stars brighten, lean toward it and join it with fine lines. Click or tap to set off a supernova, a shock wave that pushes the stars outward; they spring back and re-link.
  • Chart is made for light pages: ink dots, hairlines, a faint grid with a degree scale and Greek letters on the figure stars, on paper. Any light background colour switches the sky to that style.
  • It fills its parent and shares a single animation frame with every other instance on the page. It pauses off screen and in a background tab, lowers its resolution and star count automatically when frames run slow, and draws one composed still frame, with a figure in place, under prefers-reduced-motion. Before the first frame, and without a canvas, you see an SVG poster in the same colours.

See all effects