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://ashutoshtiwari.me/r/particle-text.json

Usage

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

API Reference

PropTypeDefaultDescription
textstringrequiredText string to render as a matrix of interactive dots.
fontSizenumber200Font size in pixels (automatically auto-clamped to fit container).
fontFamilystring"Inter"Font family used to rasterize the text glyphs on the canvas.
particleSizenumber1.5Radius in pixels of each individual dot.
particleDensitynumber6Grid spacing step between dots. Lower numbers create denser dots.
colorstringcurrentColorCustom dot color. Defaults to automatic light/dark mode theme color.
enableHoverbooleantrueEnables interactive cursor repulsion and spring return physics.
enableTwinklebooleantrueEnables sporadic starry twinkling opacity shimmer.
minOpacitynumber0.3Minimum opacity for the dimmest twinkle state (0.05 to 0.8).
twinkleSpeednumber0.01Speed multiplier for twinkle opacity transitions.
randomnessnumber0.25Probability factor (0.0 to 1.0) controlling twinkle frequency.
dispersionStrengthnumber0.05Repulsion force multiplier when hovered by the cursor.
returnSpeednumber0.08Spring physics return speed back to original coordinates.
interactionRadiusnumber100Distance in pixels around the mouse cursor within which particles react.
classNamestring""Additional CSS classes applied to the canvas container.