Skip to content

Confetti for React

Confetti is a React effect that fires a one-shot burst of paper on demand with useConfetti().fire(), for success moments. It idles at zero cost and shows a still badge instead under reduced motion.

npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/confetti.json

Studio plan

$48

Annual, three seats, billed today.

Ready to order.

Fire from a button

origin takes an element (the burst starts at its centre) or a point of the viewport. Never let confetti be the only sign of success: the text below changes too. With reduced motion the badge appears at the top of the screen instead.

Nothing placed yet.

Files to copy

4 folders · 4 files · 4 packages
From theme/src/
  • components/confetti/
  • lib/{canvas-effects.ts, cn.ts}
  • hooks/{use-media-query.ts, use-preferences.ts}
  • styles/
shadcn CLI
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/confetti.jsonRegistry item: confetti. The styles need the Tailwind v4 glass UI setup.
The examples also use
  • components/button/
  • components/spinner/
  • hooks/{use-latest.ts, use-magnetic.ts}
  • motion/{gate.ts, tokens.ts}
  • lib/{form.ts, state-light.tsx}
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/button.json
Packages
pnpm add @base-ui/react clsx motion tailwind-merge

Props

PropTypeDefaultDescription
countnumber120Sets how many pieces each burst draws.
maxCountnumber200The most pieces a single burst ever draws, whatever count asks for. Halved on weak devices.
spreadnumber75Sets the width of the fan in degrees.
anglenumber90Direction of the centre of the fan in degrees, counter-clockwise from pointing right.
velocitynumber720Sets the launch speed in px per second.
colorsstring[]the accent, second accent, success, warning and danger tokensSets the colours of the pieces, any CSS colours.
badgeReactNodeNoneShown instead of a burst when reduced motion is on, in a polite live region, so the moment is still marked (and announced). Without it a reduced-motion fire() does nothing.
badgeDurationnumber2.6Seconds the badge stays up.
classNamestringNoneAdds extra classes to the badge wrapper (a fixed, centred strip near the top).

Keyboard

KeysAction
TabNot focusable: the canvas never takes pointer events, so the page stays usable during a burst.

Accessibility

  • The canvas is decorative and aria-hidden. Always show text or a toast too; confetti is never the only sign of success.
  • Reduced motion: fire() draws nothing. With the badge prop, a still message appears for badgeDuration seconds in a polite live region (role=status), so the moment is marked and announced.
  • Nothing runs while idle. The loop exists only while pieces are in flight, then the canvas hides itself; a hidden tab ends the burst. Count is capped at 220 and halved on devices with little memory, few cores or Save-Data.
  • The canvas lives in a portal on body, never inside a glass surface, so it cannot flatten any glass.

When to use the confetti effect

  • Use it for success moments: an order placed, a goal reached, an upload finished, fired from the handler that knows it worked.
  • Fire from a button with origin set to that element so the burst starts where the user acted, or from a point of the viewport.
  • Always show text or a toast as well; confetti is decoration and never the only sign of success.
  • Skip it for routine actions, errors and anything repeated often; it should feel like an occasion.
  • Pair it with Button, Toast and the badge prop, which shows a still message instead under reduced motion.

Frequently asked questions

19 effects pages in all: browse them on All effects.

By Lokendra Singh Rathore (GitHub, opens in a new tab). Published , updated .