Components

Confetti

Paper confetti for the small victories. Strips, punched dots, stars, triangles, streamers and torn scraps, each a tiny drawing from the ink engine, thrown from a click, a state change or a function call. Nothing moves with reduced motion.

Install

terminal
npx shadcn@latest add @wobko/confetti

First time here? Add the registry to components.json first. How to install

Examples

Default

Click the button. Pieces leave it in a cone, slow down like paper, sway and fade.

Ring, streamers, one color

spread 360 sends a ring; shapes and colors narrow the pieces. A Valentine's burst of pink dots and stars.

Finishing the list

A real use: confetti stays inside the card and goes off when the last task is ticked. Untick one and tick it again for another go.

API reference

ConfettiTrigger

A button (or, with asChild, any element) that throws confetti from itself when clicked. It renders no layer of its own: the pieces fly in a click-through layer on the page.

PropTypeDefaultDescription
asChildboolean-Wrap your own element (a Button) instead of rendering a <button>.
…ConfettiOptionscount, spread, angle, velocity, gravity, drift, duration, colors, shapes, scalar, seed, origin, onDone-See the options below. The origin defaults to the trigger.

Confetti

A decorative layer that fills its positioned parent and throws inside it: when `active` turns true, whenever `burstKey` changes, or from `apiRef.burst()`. Use it to keep a burst inside a card or a dialog.

PropTypeDefaultDescription
activeboolean-Throw a burst when it turns true (or is true on mount).
burstKeynumber | string-Throw again whenever it changes: bump a counter.
apiRefRef<{ burst(options?) => () => void }>-Imperative handle.
countnumber70Pieces, at most 400.
spread / anglenumber70 / 90The cone in degrees and its direction (90 up, 0 right, spread 360 for a ring).
velocity / gravity / driftnumber1100 / 520 / 0Launch speed of the fastest piece (px/s), fall (px/s²) and wind (px/s²).
durationnumber2600ms until the last piece has faded.
colors / shapesConfettiColor[] / ConfettiKind[]-Stationery accents (tomato … bubblegum) and shapes (strip, dot, star, triangle, curl, scrap).
scalarnumber1Size multiplier.
seednumber-Same seed, same burst. Default: a counter, so every burst is different.
onDone() => void-Called once when the last piece has landed, or when the burst was cleared. A Confetti layer forgets a burst the moment it is over.

Accessibility

  • Confetti is decoration: the pieces are aria-hidden, never focusable, and click-through (pointer-events: none). Say what happened in words too (a toast, a status line): confetti alone tells a screen reader nothing.
  • Reduced motion (the OS setting, data-motion="reduced", or --ll-motion 0) throws nothing at all: no pieces, no layer.
  • Pieces are removed as soon as they have faded, and the layer with them; a burst can be canceled with the function it returns, and unmounting a Confetti layer clears its pieces.
  • Flight runs on the Web Animations API (off the main thread). Browsers without it simply show nothing.

Source

The files the CLI copies into your project.

Loading the source