Components

Particles

An interactive particles background for React: a drifting canvas field that parts around the cursor or gathers toward it, with optional constellation lines between neighbours. Sharp on high-DPI screens, resizes with its container and pauses off-screen.

  • Background
  • Canvas
  • Cursor interaction
  • Pauses off-screen
  • Reduced-motion safe

Connect your services

Link databases, queues and APIs in one private network.

Installation

$ npx shadcn@latest add https://duskui.com/r/particles.json

The canvas fills its nearest positioned parent, so give the parent relative and overflow-hidden, and put your content after it with relative so it sits on top. The pointer is tracked on the window, so content on top stays fully clickable.

Usage

hero.tsx
import { Particles } from "@/components/dusk/backgrounds/particles"

export function Hero() {
  return (
    <section className="relative overflow-hidden">
      <Particles connect />
      <div className="relative">{/* your content */}</div>
    </section>
  )
}

Examples

Attract

interaction="attract" pulls particles toward the cursor. radius and strength set its reach and pull, and a low ease makes particles trail behind.

interaction="attract"

Particles gather around the cursor; a lower ease makes them trail behind.

Starfield

Many tiny particles, a slow speed and interaction="none" make a calm, twinkling starfield.

1,204,388

stars catalogued this week

API Reference

Any other div prop is passed to the root. Positions are stored relative to the container, so resizing never reshuffles the field. Connecting lines compare every pair, so keep quantity under a couple of hundred when connect is on.

PropTypeDefaultDescription
quantitynumber50Number of particles.
colorstring"rgb(255 255 255)"Particle and line color. Any CSS color.
sizenumber1.1Average particle radius in px.
easenumber0.08How quickly particles react and settle, from 0 to 1.
interaction"repel" | "attract" | "none""repel"What the cursor does to nearby particles.
radiusnumber120Reach of the cursor in px.
strengthnumber1Strength of the push or pull.
connectbooleanfalseDraw lines between nearby particles.
connectDistancenumber110Maximum length of a connecting line in px.
speednumber1Drift speed multiplier; 0 holds particles in place.
seednumber1Layout seed; the same seed always scatters the same field.
classNamestring—Merged onto the absolutely positioned root.

Accessibility

  • The canvas is decorative: it is aria-hidden and pointer-events-none, so it never reaches screen readers or blocks clicks.
  • With prefers-reduced-motion a single still frame is drawn and the cursor interaction is turned off.
  • The animation loop stops while the canvas is off-screen or the tab is hidden.
  • Keep foreground text on a card or away from dense areas to maintain contrast.