Skip to content
Knsept
Free playbook

Confetti burst

A celebration burst from a button, drawn on a canvas with simple physics. Under 60 lines, no library.

JavaScriptUI Widgets Updated Oct 23, 2026
Live demo Reduced motion is on, so effects are toned down
<button class="celebrate" type="button">Publish 🎉</button>
<canvas class="confetti-canvas" aria-hidden="true"></canvas>

Each piece of confetti is a plain object: position, velocity, rotation, spin, size and color. Every frame applies gravity (adds to the downward speed) and drag (shrinks both speeds slightly), which is enough physics to make the arc feel natural. Pieces are removed once they fall off-screen, and the loop stops when none are left, so nothing runs when it's idle.

The canvas is sized in device pixels and scaled back with setTransform, so the confetti stays sharp on high-density screens. pointer-events: none keeps it from blocking clicks underneath.

With reduced motion on, the burst uses a third as many pieces and they don't spin.

More from the library

Feedback live

Loading-state button

A submit button that shows a spinner while it works, then success or an error, without changing width.

Feedback live

Progress ring

A circular progress indicator from one SVG circle and stroke-dasharray, with an accessible progressbar role.

Feedback live

Skeleton loader

Shimmering placeholders that hold the layout while content loads, so nothing jumps when it arrives.