Physics-Based Confetti Cannon
ProHand-rolled canvas particles with gravity, drag, terminal velocity, and paper ribbons that flutter on the way down.
show offconfetticannonframer motiontabler icons react
Installation
Run the following command
~/your-project
pnpm dlx wensity@latest add confetti-cannon
Usage
Import ConfettiCannon from @/components/wensity/confetti-cannon and render it anywhere in your React or Next.js app. The source lands in your own repo, so every prop, class and animation below is yours to edit.
app/example.tsx
import {ConfettiCannon,type ConfettiCannonHandle,} from "@/components/wensity/confetti-cannon";import { useRef } from "react";export default function Example() {const cannonRef = useRef<ConfettiCannonHandle | null>(null);return (<div><ConfettiCannonapiRef={cannonRef}origin="bottom"loopMs={0}autoFire={false}/><button onClick={() => cannonRef.current?.fire()}>Celebrate</button></div>);}
Props
| Prop | Type | Default | Description |
|---|---|---|---|
origin | ConfettiOrigin | "bottom" | Where bursts originate by default (named edges or { x, y }). |
autoFire | boolean | false | Auto-fire on mount. |
loopMs | number | 0 | Auto-fire every N ms. 0 disables looping. |
showTrigger | boolean | true | Render the demo Fire button. |
triggerLabel | string | "Celebrate again" | Demo trigger label. |
