Physics-Based Confetti Cannon

Pro

Hand-rolled canvas particles with gravity, drag, terminal velocity, and paper ribbons that flutter on the way down.

show offconfetticannonframer motiontabler icons react
Physics-Based Confetti Cannon component preview

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>
<ConfettiCannon
apiRef={cannonRef}
origin="bottom"
loopMs={0}
autoFire={false}
/>
<button onClick={() => cannonRef.current?.fire()}>Celebrate</button>
</div>
);
}

Props

PropTypeDefaultDescription
originConfettiOrigin"bottom"Where bursts originate by default (named edges or { x, y }).
autoFirebooleanfalseAuto-fire on mount.
loopMsnumber0Auto-fire every N ms. 0 disables looping.
showTriggerbooleantrueRender the demo Fire button.
triggerLabelstring"Celebrate again"Demo trigger label.