Particle Loader

A canvas dot-matrix loader that shimmers, forms text, a scene, or an orb, then dissolves and loops.

Sketching the scene
0%

Installation

  1. 1

    Install the component:

    npx shadcn@latest add https://ui.amines.fun/r/particle-loader.json
  2. 2

    Usage:

    jsx

    app/page.jsx

    <ParticleLoader variant="text" text="loading..." label="Preparing your result" progress="auto" />

Props

PropTypeDefaultDescription
variant"text" | "scene" | "orb""text"Target shape formed by the particle grid: text, a drawn or image scene, or a rotating orb.
textstring | string[]"generating..."Word or words the dots form in text mode. An array cycles its entries each loop.
scene((ctx: CanvasRenderingContext2D, width: number, height: number, options: { colors: string[]; cell: number }) => void) | string | Array<((ctx: CanvasRenderingContext2D, width: number, height: number, options: { colors: string[]; cell: number }) => void) | string>undefined (uses the built-in scene in scene mode)Scene-mode target as a canvas drawing function, image URL, or array of targets to cycle through. Images need CORS headers to be read by canvas.
colsnumbervariant-specific: 72 for text, 48 for scene, 31 for orbNumber of particle columns in the grid. Higher resolution uses more canvas work.
rowsnumbervariant-specific: 24 for text, 32 for scene, 31 for orbNumber of particle rows in the grid. Higher resolution uses more canvas work.
colorsstring[]["#a23b6c", "#e0505a", "#ef7d3d", "#f7b23c"]Palette of CSS colors flowing across particles from darker to brighter.
baseColorstring"#ffffff"CSS color for idle dots before the target shape forms.
baseOpacitynumber0.1Opacity of the idle grid dots, from 0 to 1.
hoverColorstringundefined (lightened from the last palette color)CSS color used for dots near the pointer.
dotSize[number, number][0.12, 0.8]Minimum and maximum particle radius as fractions of the grid cell pitch.
shape"circle" | "square" | "diamond""circle"Shape drawn for each particle.
glownumber0.5Strength of the halo around larger dots, from 0 to 1.
speednumber1Multiplier for the loader's animation clock.
morphSpeednumber1Speed multiplier for particles settling into their target shape.
shimmerTimenumber2.6Seconds each loop spends shimmering before forming the target.
holdTimenumber4Seconds to hold the formed target. Infinity keeps the shape from dissolving and looping.
pausedbooleanfalseFreeze animation time while keeping pointer interaction active.
hoverbooleantrueEnable the pointer reaction that pushes and enlarges nearby dots.
hoverRadiusnumber5Pointer influence radius in grid cells.
hoverStrengthnumber1.1Maximum distance nearby dots are pushed, in grid cells.
hoverBoostnumber0.55Additional dot size from pointer proximity.
hoverSpring{ stiffness: number; damping: number }{ stiffness: 140, damping: 20 }Framer Motion spring options for the pointer reaction fade.
ripplebooleantrueSend a shockwave through the grid on pointer down.
fontFamilystring"ui-sans-serif, system-ui, sans-serif"CSS font family used to rasterize text targets.
fontWeightnumber800Font weight used to rasterize text targets.
labelstring | string[] | null"Generating" (text), ["Creating image", "Sketching it out", "Adding details"] (scene), or ["Thinking", "Connecting the dots"] (orb); null hides itCaption above the grid. Arrays cycle through labels every labelInterval milliseconds.
labelIntervalnumber2800Milliseconds between caption changes when label contains multiple entries.
progressnumber | "auto"undefined (no progress pill)Show a percentage pill. A number sets a value from 0 to 100; auto animates a repeating progress cycle.
ariaLabelstring"Loading"Accessible label on the loader's status region.
classNamestring"rounded-2xl bg-black p-5 text-neutral-300"Additional Tailwind classes appended to the root's built-in layout and the default styling.
labelClassNamestring"mb-4 text-sm font-medium text-neutral-300"Tailwind classes replacing the default caption styling.
pillClassNamestring"absolute bottom-2 right-2 rounded-full bg-white/10 px-3 py-1.5 text-sm font-medium tabular-nums text-sky-400 backdrop-blur-md"Tailwind classes replacing the default progress pill styling.
...restReact.HTMLAttributes<HTMLDivElement>undefinedOther native div attributes such as id, data-*, and additional accessibility attributes, spread onto the status root.