UI / Decor
Snowfall
Soft snow falling over any box for as long as it is on the page, near flakes bigger and quicker, with a density setting.
Installation
npx shadcn@latest add https://jiaweing.com/r/snowfall.jsonWith the @jiaweing namespace set up, use @jiaweing/snowfall in place of the URL.
Usage
tsx
import { Snowfall } from "@/components/room/snowfall";tsx
<div className="relative h-80 bg-slate-900">
<Snowfall density={1.5} />
</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.
- It snows for as long as it is on the page. The default white needs something darker behind it.
- With reduced motion, the flakes hang still in the air.
Props
Snowfall
| Prop | Type | Default | Description |
|---|---|---|---|
| density | number | 1 | 1 is a flake for every 100 by 100 pixels. |
| speed | number | 1 | 1 is a gentle fall. |
| colors | string[] | paper white | 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.