Particle Text

Interactive canvas-based dot particle text with starry twinkling shimmer and cursor hover dispersion physics.

1import { ParticleText } from "@/components/particle-text";
2 
3export default function ParticleTextDemo() {
4 return (
5 <div className="w-full flex items-center justify-center py-6">
6 <ParticleText
7 text="Skills"
8 enableHover={true}
9 enableTwinkle={true}
10 fontSize={160}
11 />
12 </div>
13 );
14}

Installation

bunx --bun shadcn@latest add https://www.ashutoshtiwari.is-a.dev/r/particle-text.json

Usage

1import { ParticleText } from "@/components/particle-text"
1<ParticleText text="Skills" />

API Reference

PropTypeDefaultDescription
textstringrequired

Text string to render as a matrix of interactive dots.

fontSizenumber200

Font size in pixels (automatically auto-clamped to fit container).

fontFamilystring"Inter"

Font family used to rasterize the text glyphs on the canvas.

particleSizenumber1.5

Radius in pixels of each individual dot.

particleDensitynumber6

Grid spacing step between dots. Lower numbers create denser dots.

colorstringcurrentColor

Custom dot color. Defaults to automatic light/dark mode theme color.

enableHoverbooleantrue

Enables interactive cursor repulsion and spring return physics.

enableTwinklebooleantrue

Enables sporadic starry twinkling opacity shimmer.

minOpacitynumber0.3

Minimum opacity for the dimmest twinkle state (0.05 to 0.8).

twinkleSpeednumber0.01

Speed multiplier for twinkle opacity transitions.

randomnessnumber0.25

Probability factor (0.0 to 1.0) controlling twinkle frequency.

dispersionStrengthnumber0.05

Repulsion force multiplier when hovered by the cursor.

returnSpeednumber0.08

Spring physics return speed back to original coordinates.

interactionRadiusnumber100

Distance in pixels around the mouse cursor within which particles react.

classNamestring""

Additional CSS classes applied to the canvas container.