UI / Decor
Sparkle Burst
A ring of little foil gems thrown out and up from any spot, the burst the 3D room makes when a figure is found.
0 of 6 found
Press a tile to find what is under it. The pad sparks wherever you press it.
Installation
npx shadcn@latest add https://jiaweing.com/r/sparkle-burst.jsonWith the @jiaweing namespace set up, use @jiaweing/sparkle-burst in place of the URL.
Usage
tsx
import { SparkleBurst } from "@/components/room/sparkle-burst";tsx
const burst = useRef<SparkleBurstHandle>(null);
<div className="relative h-80" onClick={(e) => {
const r = e.currentTarget.getBoundingClientRect();
burst.current?.fire({
x: (e.clientX - r.left) / r.width,
y: (e.clientY - r.top) / r.height,
});
}}>
<SparkleBurst ref={burst} />
</div>- It draws on a see-through canvas over its parent and takes no clicks.
- three.js is only fetched in the browser, the first time it is needed.
- With reduced motion, nothing bursts.
Props
SparkleBurst
| Prop | Type | Default | Description |
|---|---|---|---|
| ref | Ref<{ fire: (at?: { x, y }) => void }> | - | fire() bursts at a spot, x across and y down, each 0 to 1. |
| trigger | unknown | - | Sets it off each time it becomes a new value that is not false, 0 or empty: a flag going true, or a count going up. |
| at | { x: number; y: number } | { x: 0.5, y: 0.5 } | Where a burst goes off when fire() is not told. |
| count | number | 16 | Gems a burst. |
| size | number | 1 | How big a burst is. 1 is about 200 pixels across. |
| colors | string[] | the 2026 gradient | Any CSS colours, oklch() and color-mix() included. |
| className | string | - | Classes on the layer. It lies over its parent, so give the parent a position. |
MIT licensed. Copy it, change it, ship it.