Calm motion: animations on this site only fade, with no movement
Confetti
A burst of paper for the moment something goes right
A short celebration for a finished task, a sent message, or a first sale. You fire it from code, and there is nothing on the page until you call fire(). Use it for one moment that the reader earned, not as decoration. For a message that has to be read, use Toaster or Alert. Confetti carries no words.
Fire from a button
- Put one
<BlessConfetti ref="confetti" />in the page and callconfetti.fire(from?, angle?).fromis an element to burst out of, a{ x, y }point in viewport pixels, or nothing for the lower middle of the window.anglepoints the cone (default 270°, straight up). Fire several times and the bursts overlap. - It draws on one canvas over the page. The canvas lets every click through. It removes the pieces after
duration, or when they leave the bottom of the window.finishfires when the last piece is gone. - With
prefers-reduced-motionnothing is drawn andfinishfires at once. The canvas is hidden from screen readers, so say what happened in words too (anaria-liveline, a toast). The burst is only the cheer. colorstakes token names (chart-2,warning…) or CSS colors.count,spread(360 = all around),powerandgravityshape the burst.
Usage
ts
import { BlessConfetti } from "blessing-ui";API
Props
| Name | Type | Default | Description |
|---|---|---|---|
count | number | 90 | pieces per burst |
colors | string[] | ["chart-1", "chart-2", "chart-3", "chart-4", "chart-5", "warning"] | token names (`chart-2`, `accent`…) or CSS colours |
duration | number | 2200 | milliseconds until the last piece has faded |
spread | number | 80 | width of the cone the pieces leave in, degrees; 360 is all around |
power | number | 900 | launch strength, px per second |
gravity | number | 1400 |
Events
| Name | Payload | Description |
|---|---|---|
finish | [] |
Exposed
| Name | Type | Description |
|---|---|---|
fire | (from?: HTMLElement | { x: number; y: number; } | undefined, angle?: number) => undefined | |
stop | () => void |