UI / Decor
Ember Shower
Glowing embers that fall from above the top edge, turning as they go, and burn out.
Installation
npx shadcn@latest add https://jiaweing.com/r/ember-shower.jsonWith the @jiaweing namespace set up, use @jiaweing/ember-shower in place of the URL.
Usage
tsx
import { EmberShower } from "@/components/room/ember-shower";tsx
const [n, setN] = useState(0);
<div className="relative h-80 bg-stone-950">
<button onClick={() => setN((x) => x + 1)}>Strike</button>
<EmberShower trigger={n} />
</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 falls.
Props
EmberShower
| Prop | Type | Default | Description |
|---|---|---|---|
| ref | Ref<{ fire: () => void }> | - | fire() starts a shower. |
| 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. |
| count | number | 34 | Embers a shower. |
| colors | string[] | gold to red | 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.