Skip to content
WANCRAFT

H.303D & Experimental

Particle Sphere

A rotating Fibonacci-lattice particle sphere on canvas that tilts toward and parts around the pointer.

ReactCanvasadvanced
Move the pointer across the sphere

Overview

Particle Sphere distributes points evenly over a sphere with a Fibonacci lattice, rotates and projects them with perspective onto a 2D canvas, and shades them by depth from a secondary colour on the far side to your main colour in front. The pointer tilts the sphere and repels or attracts nearby particles with a smooth falloff. Particles are drawn in a handful of depth-batched paths, the canvas is devicePixelRatio-aware (capped at 2), and adaptive mode trims the count on small screens or when the frame rate drops. The loop pauses offscreen and in background tabs; reduced motion renders a single still frame.

01Installation

Method 01 · Registry

CLI verified

Uses the shadcn CLI in a project initialised with shadcn init. Installs the file to components/ui/particle-sphere.tsx and adds its dependencies.

npx shadcn@latest add https://wancraft.my/r/particle-sphere.json

Method 02 · Copy and paste

  1. 1. No extra dependencies — React and Tailwind CSS only.
  2. 2. Copy the source from the Code tab into components/ui/particle-sphere.tsx.
  3. 3. Import it and adjust props.
Dependencies
None
Peer
react ≥ 18, tailwindcss ≥ 4
Added
1 Oct 2026
Updated
—

02Usage

The default configuration. Change properties above to generate a tailored example in the Usage tab.

example.tsx
import { ParticleSphere } from "@/components/ui/particle-sphere";

export function ParticleSphereExample() {
  return (
    <div className="relative h-[420px] w-full">
      <ParticleSphere label="Rotating particle globe" />
    </div>
  );
}

03Props

PropTypeDefaultDescription
colorstring"#FF7448"Hex colour of particles facing the viewer.
secondaryColorstring"#B6F3D1"Hex colour particles fade toward on the far side.
densitynumber900Particle count before adaptive reduction.
sizenumber1.6Particle radius in CSS px (scaled by depth).
speednumber1Rotation speed multiplier; 0 stops the spin.
radiusnumber0.36Sphere radius as a fraction of the smaller container side.
interaction"repel" | "attract" | "none""repel"How particles react to the pointer.
tiltbooleantrueTilt the sphere toward the pointer.
adaptivebooleantrueUse 60% of particles under 520px wide and shed 25% when below ~40fps.
glowbooleantrueSoft radial halo behind the sphere.
labelstring—Accessible label (role="img"). Omit for a purely decorative, aria-hidden sphere.
...propsHTMLAttributes<HTMLDivElement>—Forwarded to the root element, which fills its parent.

04Features

  • 01Fibonacci-lattice distribution with perspective projection
  • 02Depth-shaded two-colour gradient in batched paths
  • 03Pointer tilt plus repel / attract with smooth falloff
  • 04Adaptive particle count for small screens and slow frames
  • 05DPR-aware canvas (capped at 2) with ResizeObserver
  • 06Pauses offscreen and in hidden tabs
motion · continuousinput · pointerinput · hover

05Accessibility

  • Decorative by default: the root is aria-hidden. Pass label to expose it as role="img" with that name.
  • The canvas itself is always aria-hidden; no information depends on the animation.
  • With prefers-reduced-motion a single static frame is drawn and pointer effects are disabled.

06Limitations

  • Canvas 2D is CPU-bound: beyond ~3,000 particles consider WebGL.