Particle Shape Background

A full-bleed canvas of tiny particles where a hidden shape — world map, rotating globe, text, image, heart, or your own math function — decides which particles light up. Nine animations (drift, assemble, wave, pulse, scan, morph...) move the shape behind your content, with cursor repel, parallax, and readability dimming built in.

Particle shapes

A world map, drawn by particles.

Thousands of tiny particles light up to form a hidden shape, then drift, assemble, and ripple behind your content. The cursor pushes them aside and the whole layer parallaxes gently.

9 animationsCustom shapesReadability dimming

Installation

  1. 1

    Install the component:

    npx shadcn@latest add https://ui.amines.fun/registry/particle-shape-background.json
  2. 2

    Usage:

    jsx

    app/page.jsx

    import ParticleShapeBackground from "@/components/ui/particle-shape-background";// Easiest: wrap your content — particles dim themselves behind text<ParticleShapeBackground shape="map" animation="drift" className="min-h-screen">  <h1 className="text-5xl font-bold text-white">Got an idea worth building?</h1></ParticleShapeBackground>// Or as a layer inside your own relative section<section className="relative min-h-screen overflow-hidden bg-[#0b0b0d]">  <ParticleShapeBackground shape="globe" animation="float" />  <div className="relative z-10">...your content...</div></section>// Cycle several animations automatically<ParticleShapeBackground  shape="map"  animation={["drift", "assemble", "wave", "pulse", "scan"]}  cycleSeconds={12}/>// Morph between shapes — particles dissolve and re-form<ParticleShapeBackground  animation="morph"  morphShapes={["map", "globe", "heart", "star"]}  text="AB"/>

Props

PropTypeDefaultDescriptionRequired
childrenReactNode-Optional content rendered above the particles inside a relative wrapper.No
classNamestring""Extra classes for the particle layer itself.No
containerClassNamestring""Extra classes for the outer wrapper (only used when children are provided).No
contentClassNamestring""Extra classes for the content holder above the particles.No
styleReact.CSSProperties-Inline styles for the particle layer.No
backgroundColorstring"transparent"Background color of the particle layer.No
fadeInDurationnumber1.2Entrance fade-in duration in seconds.No
shape"map" | "globe" | "circle" | "ring" | "heart" | "star" | "text" | "image" | "custom""map"Which shape the particles form: built-in world map, rotating globe, text, image mask, analytic shapes, or a custom function.No
textstring"AB"Text drawn when shape="text".No
textFontFamilystring"ui-sans-serif, system-ui, sans-serif"CSS font-family for the text shape.No
textFontWeightnumber900CSS font-weight for the text shape.No
imageSrcstring""Image URL when shape="image" — use a same-origin or CORS-enabled image (a high-detail map PNG/SVG works well).No
imageMode"alpha" | "light" | "dark""alpha"How the image becomes a particle mask: visible pixels, bright pixels, or dark pixels.No
customShape(u: number, v: number, t: number) => numbernullCustom shape function for shape="custom". u/v run 0..1 across the shape box, t is seconds; return 0..1 for how lit each point is.No
customShapeAspectnumber1Width/height aspect of the custom shape box.No
shapeScalenumber0.9How much of the container the shape may fill, 0 to 1.No
shapePosition{ x: number, y: number }{ x: 0, y: 0 }Shape offset as a fraction of the container, e.g. { x: -0.2, y: 0.1 } moves it left and down.No
globeSpeednumber0.25Rotation speed of the globe shape in radians/second.No
animationstring | string[]"drift"One animation name, or an array to cycle through. Options: "none", "drift", "float", "assemble", "wave", "pulse", "scan", "twinkle", "morph".No
speednumber1Global animation speed multiplier. 0.5 is slow motion, 2 is double speed.No
cycleSecondsnumber12Seconds each animation plays when animation is an array.No
direction"right" | "left" | "down" | "up""right"Travel direction for drift and scan animations.No
driftSpeednumber35Drift speed in pixels per second.No
morphShapesstring[]["map", "globe", "heart", "star"]Shapes cycled through by the morph animation.No
morphSecondsnumber5Seconds each shape stays before morphing to the next.No
assembleSecondsnumber8Length of one assemble → hold → disperse loop in seconds.No
scatterDistancenumber0.5How far particles fly during assemble/morph, as a fraction of the container's shorter side.No
waveAmplitudenumber10Wave height in px for the wave animation.No
pulseSpeednumber220Ring speed in px/s for the pulse animation.No
scanSpeednumber260Beam speed in px/s for the scan animation.No
pausedbooleanfalseFreeze the animation.No
gapnumber14Distance between particles in px. Smaller values are denser; it is enlarged automatically to respect maxParticles.No
maxParticlesnumber9000Safety cap on particle count — the gap grows automatically if the grid would exceed it.No
particleSizenumber2.2Base particle radius in px.No
particleStyle"mixed" | "ring" | "dot" | "square" | "plus""mixed"Particle glyphs: a seeded mix of rings/dots/plus signs, or one style for all particles.No
strokeWidthnumber1Line width for ring and plus particles.No
colorsstring[]["#e5e7eb", "#e5e7eb", "#93c5fd", "#a5b4fc", "#fde68a", "#c4b5fd"]CSS colors the particles cycle through.No
colorMode"random" | "horizontal" | "vertical""random"How colors are distributed over the particle grid.No
opacitynumber0.85Brightness of lit particles, 0 to 1.No
ghostOpacitynumber0.04Visibility of particles outside the shape, 0 to 1. Set to 0 for a fully invisible field until lit.No
sparklebooleantrueRandom stars twinkle in the empty areas.No
sparkleDensitynumber0.035Share of particles that can sparkle, 0 to 1.No
seednumber7Seed for the random particle layout — change it for a different stable arrangement.No
maxDprnumber2Maximum device pixel ratio. Lower values are faster on weak GPUs.No
mouseEffect"both" | "repel" | "glow" | "none""both"Cursor interaction: particles are pushed away, glow near the cursor, both, or neither.No
mouseRadiusnumber140Radius of the cursor effect in px.No
mouseStrengthnumber22How far particles are pushed away from the cursor, in px.No
parallaxnumber12Pixels the whole layer shifts with the cursor. 0 disables parallax.No
contentDimnumber0.45How much particles fade behind your content area, 0 to 1 — keeps text readable.No
contentDimArea{ x: number, y: number, width: number, height: number }{ x: 0.5, y: 0.5, width: 0.7, height: 0.5 }Ellipse (as container fractions) where particles dim — match it to your text block.No
edgeFadenumber0.3Fades the layer out toward the edges, 0 to 1.No
respectReducedMotionbooleantrueShow a calm static frame for visitors who prefer reduced motion.No