A burst of particles around a trigger, for likes and stars.
Installation
Install the packages
npm install @prequelui/react motion@prequelui/react reuses the primitive library your components already depend on.
Add the component
npx shadcn@latest add https://animate.prequelui.terravidhal.me/r/particles.jsonnpx shadcn@latest add https://animate.prequelui.terravidhal.me/r/particles.json
Turn on the motion
npx @prequelui/cli@latest animate particlesThe CLI finds the component through components.json, swaps the import and removes the CSS animation classes that Motion replaces.
Usage
Import the component and compose it exactly like the primitive it wraps. Motion is enabled by default; the tempo prop scales every duration and softens every spring.
import { Particles, ParticlesEffect } from "@/components/prequelui/effects/particles";
export default function Demo() {
const [burst, setBurst] = useState(0);
return (
<Particles>
<button onClick={() => setBurst((value) => value + 1)}>Celebrate</button>
<ParticlesEffect key={burst} side="top" count={10} radius={48} color="#f5b301" />
</Particles>
);
}import { Particles } from "@/components/prequelui/particles";
export function Variant() {
return (
<Particles tempo={1.2}>
…
</Particles>
);
}Animation
A particles container coordinates a burst of dots around itself. Each dot leaves from one side of the container, travels to its place on a circle and shrinks back to zero, with a small stagger between neighbours.
- Default travel: 0.8 s ease-out with a 50 ms step between particles.
- Side and align place the burst on any edge or corner of the container.
- The burst only plays when the container is in view and motion is allowed.
- Particles are decorative, aria-hidden and pointer-events none.
API Reference
Each part accepts the usual HTML props in addition to the motion props below. No accessibility prop is hidden behind the animation layer.
Particles
| Prop | Type | Default |
|---|---|---|
| animate | boolean | true |
| inView | boolean | false |
| inViewOnce | boolean | true |
| className | string | — |
ParticlesEffect
| Prop | Type | Default |
|---|---|---|
| side | "top" | "bottom" | "left" | "right" | "top" |
| align | "start" | "center" | "end" | "center" |
| count | number | 6 |
| radius | number | 30 |
| spread | number | 360 |
| duration | number | 0.8 |
| holdDelay | number | 0.05 |
| size | number | 4 |
| color | string | "currentColor" |