Cosmic & Space
Twinkling Starfield
115 multicolor stars twinkle via sine waves; sparkle crosses appear on larger stars; stars brighten near cursor. Static fallback for reduced-motion.
canvaslight complexitysubtle motionpointermobile-readyaccessible
Open on the canvas to copy the code → Free account · 3 copies a day · membership goes unlimited
Worth keeping?
Votes steer what gets built next — sign in to cast one, free to read
When to use it
Dark-mode hero backgrounds, space/night themes, ambient looping screensavers.
When not to
Light-background UIs (background hardcoded dark navy). Content-heavy layouts where motion competes with reading.
Working with an AI agent
Every component ships agent-ready metadata. An example instruction for this one:
Increase star count to 200, change palette to warm amber/orange tones, add a slow drift so stars move across the canvas.
Safe to edit
- star count (N=115)
- color palette (cols array)
- twinkle speed (t += 0.03)
- sparkle threshold (rr > 1.6)
- cursor influence radius
Keep intact
- DPR-aware canvas sizing
- visibility pause
- reduced-motion static fallback
- IIFE wrapper
Known limitations
- Background color hardcoded in CSS — must edit to change from dark navy
More Cosmic & Space components
- Orbiting Planet SystemFour glowing planets orbit a radiant sun on tilted elliptical rings with depth-sorted rendering; the system drifts subtly toward the pointer.
- Black-hole Accretion Swirl110 heat-colored particles spiral inward across a tilted accretion disk toward a glowing event horizon; pointer movement boosts swirl speed.
- Spiral Galaxy Rotate115 stars form a two-armed spiral galaxy rotating around a violet radial-gradient core; pointer move briefly doubles spin speed.
- Comet Streak LoopCyan and violet comets with glowing heads and gradient tails streak diagonally across a twinkling dark starfield; click spawns an extra comet (up to 5).
- Ringed Planet RotateAmber gas giant with tilted Saturn-like rings slowly rotates over a twinkling starfield; pointermove adjusts ring tilt and light angle dynamically.
- Constellation Connect46 drifting star nodes auto-connect with faint magenta lines when close; cursor draws lines to nearby stars and brightens them on hover.