# Particles

> React canvas background of drifting particles that repel or attract around the pointer, colored from your accent token and sharp on high density screens.

- Kind: Motion component (Motion)
- Docs: https://ui.minidev.pro/docs/particles
- Source (registry JSON with the full file): https://ui.minidev.pro/r/particles.json
- License: MIT. One file, yours to edit after install.

## When to use

Use it behind a hero or CTA panel that should feel alive under the pointer. Reach for Meteors for streaks, LightField for a soft WebGL glow, and DotPattern or FlickeringGrid for a static or barely moving texture.

## Installation

### shadcn CLI (copies the source into your project)

```bash
npx shadcn@latest add @minidev/particles
```

Writes `components/ui/particles.tsx` plus the MiniDev files it is built from (button) and installs its npm dependencies. Older CLI versions: `npx shadcn@latest add https://ui.minidev.pro/r/particles.json`.

### npm package

```bash
npm i minidev-ui-kit lucide-react motion
```

Add the tokens to your global stylesheet once:

```css
@import "tailwindcss";
@import "minidev-ui-kit/styles.css";
@source "../node_modules/minidev-ui-kit";
```

Next.js also needs `transpilePackages: ["minidev-ui-kit"]` in next.config.

## Import

After the shadcn install:

```tsx
import { Particles } from "@/components/ui/particles"
```

From the npm package:

```tsx
import { Particles } from "minidev-ui-kit/premium/particles"
```

## Usage

```tsx
import { Particles } from "@/components/ui/particles"

export function Example() {
  return (
    <Particles />
  )
}
```

## Props

| Prop | Type | Default | Required | Description |
| --- | --- | --- | --- | --- |
| `quantity` | `number` | `110` | no | Number of particles. |
| `size` | `number` | `2` | no | Radius of the nearest particles in pixels. Farther ones are smaller. |
| `color` | `string` | `"var(--accent)"` | no | Any CSS colour, including var(--token). Defaults to the accent. |
| `mode` | `"repel" \| "attract"` | `"repel"` | no | Push particles away from the pointer, or pull them toward it. |
| `radius` | `number` | `120` | no | Reach of the pointer in pixels. |
| `drift` | `number` | `1` | no | Drift speed multiplier. 0 holds the field still apart from the pointer. |
| `className` | `string` | - | no |  |
| `children` | `React.ReactNode` | - | no |  |

## Examples

### Attract mode

mode="attract" pulls particles toward the pointer instead of parting around it; radius sets how far the pull reaches.

```tsx
<Particles mode="attract" radius={180} quantity={160} className="h-72">
  <div className="flex h-full flex-col items-center justify-center gap-2 px-6 text-center">
    <p className="text-2xl font-medium tracking-[-0.03em] text-fg">Move the pointer</p>
    <p className="text-sm text-fg-muted">The field gathers toward it and settles when it leaves.</p>
  </div>
</Particles>
```

### Dense and still

drift={0} holds the field in place so only the pointer moves it; a small size and the ink colour read as a starfield.

```tsx
<Particles quantity={260} size={1.5} drift={0} color="var(--fg)" className="h-64">
  <div className="flex h-full flex-col items-center justify-center gap-3 px-6 text-center">
    <span className="rounded-full border border-border bg-surface px-2.5 py-0.5 text-xs font-medium text-fg-muted">Coming soon</span>
    <p className="text-2xl font-medium tracking-[-0.03em] text-fg">Lumen Capital</p>
    <p className="max-w-xs text-sm text-fg-muted">Working capital against the invoices you have already sent.</p>
  </div>
</Particles>
```

### Email capture

Children sit above the canvas and keep the pointer, so a form works as usual; the second accent colours the dots.

```tsx
<Particles color="var(--accent-2)" quantity={80} size={2.5} className="h-80">
  <div className="flex h-full flex-col items-center justify-center gap-4 px-6 text-center">
    <p className="max-w-[20ch] text-3xl font-medium tracking-[-0.035em] text-balance text-fg">Get the Lumen 3.0 launch notes</p>
    <form className="flex w-full max-w-sm gap-2" onSubmit={(e) => e.preventDefault()}>
      <Input type="email" placeholder="maya@northwind.com" aria-label="Email" />
      <Button type="submit">Notify me</Button>
    </form>
  </div>
</Particles>
```

## Accessibility

- The canvas is `aria-hidden` and `pointer-events-none`; children render above it.
- Under reduced motion it draws one still frame and does not listen to the pointer at all.

## FAQ

### How do I make particles follow or avoid the cursor?

`mode="repel"` (default) pushes them away and `mode="attract"` pulls them in, within `radius` pixels (default 120). Pointer moves are read on the window, so it works through the content on top.

### Will Particles slow down my page?

It draws `quantity` dots (default 110) on one canvas, capped at 2x device pixels, and stops when off screen or in a background tab. Lower `quantity` for large panels on phones; `drift={0}` holds the field still except near the pointer.

## Rules for generating code

- Use semantic tokens only (bg, surface, sunken, border, fg, fg-muted, fg-subtle, ink, accent, success, warning, danger). Never raw hex or palette steps like blue-500.
- Shadows only from the set: shadow-xs, shadow-sm, shadow-raised, shadow-md, shadow-lg, shadow-overlay.
- Numbers use tabular-nums. Dark mode is the `dark` class on <html>; components never branch on theme.

## Dependencies

- npm: `lucide-react`, `motion`
- Built from: [button](https://ui.minidev.pro/docs/button/md)

## Related

- [Meteors](https://ui.minidev.pro/docs/meteors/md): React meteors background that sends accent colored streaks with fading tails falling diagonally behind your content, with count, angle and speed props.
- [Light Field](https://ui.minidev.pro/docs/light-field/md): A WebGL shader background of drifting color silk with a soft cursor light and grain. It renders at half resolution, pauses offscreen and adapts to dark mode.
- [Dot Pattern](https://ui.minidev.pro/docs/dot-pattern/md): A dot or grid background drawn as one SVG pattern, faded at the edges, with an optional accent glow that follows the pointer and lights the dots beneath it.
- [Flickering Grid](https://ui.minidev.pro/docs/flickering-grid/md): React canvas background of small squares whose opacity flickers at random, with square size, gap, flicker chance, color and radial fade mask props.
- [Ripple](https://ui.minidev.pro/docs/ripple/md): React background of concentric rings that pulse outward from the center or any point, staggered and fading, plus an extra ripple from each click or tap.
- [Wavy Background](https://ui.minidev.pro/docs/wavy-background/md): React canvas background of layered sine waves rolling behind your content, with colour, speed, amplitude and blur props, sharp on retina and paused off screen.

---

All 557 components: https://ui.minidev.pro/llms.txt (full text: https://ui.minidev.pro/llms-full.txt).
