NK

Search

Search pages, posts, and components

All components

Particle Field

Background Effects

A canvas field of drifting, twinkling particles.

Installation

Add it with the shadcn CLI:

$pnpm dlx shadcn@latest add https://nawalkattel.com.np/r/particle-field.json
Or install manually
  1. 1. Install dependencies

    pnpm add clsx tailwind-merge
  2. 2. Copy the component source into components/library/particle-field.tsx

Props

PropTypeDefaultDescription
countnumber60Number of particles.
colorstring"currentColor"Particle fill. Resolved from the element's computed text colour.
sizenumber1.6Maximum particle radius in CSS pixels.
speednumber0.4Drift speed multiplier.

Accessibility

  • Canvas is decorative - keep meaningful content in the DOM.
  • Respects devicePixelRatio, so it stays sharp on retina screens.
  • Cancels its animation frame and observer on unmount.
  • Pass a theme-aware colour so it stays visible in light and dark.

Dependencies

clsxtailwind-merge