Cut paper for a real event: two-sided pieces in the kit's shapes tumble through a key light, flutter down with real drag, land on the floor of the panel and fade.
Use it once, for a real event the person caused, fired from the handler of that event or with fireKey. It never fires or loops by itself, and the first fireKey value stays quiet.
When not to use
Too much for routine saves, every row of a dense table, forms with errors or payment steps in progress. For a moment the person launches by hand with press and hold, use Fireworks.
Use it once, for a real event the person caused: an order paid, a target reached, the last task
closed. It never fires by itself and never loops. Effects are visual pieces rather than controls:
they do not replace the Interface components in dashboards and forms.
Wrap the panel whose bottom edge is the floor, and fire from the handler of the event.
import { useRef } from "react"import { Confetti, type ConfettiHandle } from "@/components/effects/confetti"export function InvoiceRow() { const confetti = useRef<ConfettiHandle>(null) return ( <Confetti ref={confetti} className="rounded-2xl border bg-card"> <button onClick={(e) => confetti.current?.fire({ origin: e.currentTarget })}> Mark as paid </button> </Confetti> )}
fire({ origin, angle, spread, count, preset }) takes an element (its centre) or a point in
viewport pixels; angle leans the cone from straight up, in degrees. Without children the floor
is the positioned parent's bottom edge.
Pass fireKey: a burst fires every time it changes (an order id, a counter). Its first value
never fires, so a page load stays quiet. origin sets where those bursts start.
pop (default): about 40 pieces from one element, done in 1.2 s. For a checkbox or a button.
cannon: two cones from the lower corners of the panel, leaning inward. For a milestone.
drop: released along the top edge and falling slowly, ticker-tape. For midnight.
temperament (calm, lively, playful) scales the count, the reach and the squash of the
origin. gravity (a multiplier) and rest (seconds on the floor) tune the fall.
The paper defaults to your primary and chart-1 to chart-5; the back of each piece is a lighter
tint of its face. shapes picks from the kit's pieces (ball, pill, tile, half-ball,
triangle) or any SVG path with its viewBox.
The canvas is aria-hidden and pointer-events: none: it never takes a click, even mid-burst.
Announce the event itself in your own UI (a status line, a badge), not the confetti.
Nothing is triggered by the effect: the button or the event you wire to fire stays the
accessible control, keyboard included.
While pieces are in the air or on the floor, a brisk move of the hand blows them aside; a still
hand does nothing, so the button under the burst stays easy to reach.
No flight: twelve pieces fade in already lying around the origin, stay 1.2 s and fade out. The
origin does not squash. The component reads usePrefersReducedMotion, so the
MotionKitProvider setting applies too.
Nothing exists at rest: the fixed canvas is created by the first burst and removed when the last
piece fades. Device pixel ratio is capped at 2 and at most 220 pieces are alive at once.
The simulation freezes in a hidden tab or with the panel off screen, and finishes on return. A
burst fired while the panel is off screen is dropped; onComplete still runs.
Source size is checked against the 15 KB gzip budget for effects (pnpm size).
Technical sheet
Motion
calm
260 ms · bounce 0
lively
400 ms · bounce 0.3
playful
540 ms · bounce 0.45
Main spring of each temperament. Set it with the temperament prop or MotionKitProvider; the default is lively.
Size
Not measured yet · budget 15.0 kB gzip
Component and MotionKit helpers; excludes react, react-dom.
Dependencies
motion
Triggers
click, pointer movement
Reduced motion
No flight: twelve pieces fade in already at rest around the origin, stay 1.2 s and fade out.
Keyboard
No keyboard interaction of its own.
Browsers
Last 2 versions of Chrome, Edge, Firefox and Safari (iOS 16.4+)