GodUI

Particle Dissolve

Text or an image is sampled into particles that scatter and reform — a dramatic entrance or transition.

The source — a headline, a logo, or an image — is sampled into thousands of particles that fly in from scatter to form the shape, hold with a subtle shimmer, then disperse and reform. A strong second-read moment for a hero.

Installation

pnpm dlx shadcn@latest add "https://godui.design/r/particle-dissolve.json"

The source is drawn to an offscreen canvas and sampled on a grid; every opaque pixel becomes a particle whose colour is taken from the source (so images keep their colours). A single requestAnimationFrame loop eases a global form/scatter progress, with a per-particle delay for the stagger.

Usage

tsx
 
import { ParticleDissolve } from "@/components/godui/particle-dissolve";

Text

tsx
 
<ParticleDissolve text="Launch" className="text-primary" />

The particle colour follows the canvas's CSS color, so a Tailwind text utility (text-primary) just works — or pass an explicit color.

Image

tsx
 
<ParticleDissolve src="/logo.png" width={480} height={480} />

Images must be same-origin or CORS-enabled to be sampled.

Modes & triggers

mode sets the resting behaviour (assemble, disperse, or loop); trigger decides when it starts (mount, in-view, or hover).

tsx
 
<ParticleDissolve text="Hover me" mode="assemble" trigger="hover" />

Accessibility

The canvas exposes the text as its aria-label (role="img"). When prefers-reduced-motion is set, the shape is drawn once, fully formed, with no animation.

Props

PropTypeDefaultDescription
textstringText to render as particles (ignored when src set).
srcstringImage URL to sample into particles.
mode"assemble" | "disperse" | "loop""assemble"Resting behaviour once triggered.
trigger"mount" | "in-view" | "hover""in-view"When the animation starts.
densitynumber4Pixel sampling step — smaller is denser.
particleSizenumber2Particle dot size in px.
colorstringtext colorFill colour for text particles.
width / heightnumber640 / 240Canvas size in CSS px.

ParticleDissolve also forwards every standard <canvas> attribute.

On this page

Built with GodUI

Beautifully crafted motion components for modern interfaces.

Star on GitHub