Falling Snow by Fluri

Falling snow is the most searched website effect of December, and most versions are the same: white dots fall and disappear at the bottom. I wanted the snow to land on the page: build up on headings, cards and images, pile up along the bottom of the screen, and get brushed off when you swipe across it.

Falling Snow is free (MIT), about 11 KB minified, no dependencies.

Install

<script src="https://cdn.jsdelivr.net/npm/@fluritheme/falling-snow@1/dist/falling-snow.global.js" data-auto></script> 
import { createFallingSnow } from "@fluritheme/falling-snow"; const snow = createFallingSnow({ amount: 1, surfaces: "h1, h2, .card, img", // where snow settles depth: 14, // deepest pile in px melt: 90, // seconds to melt to half }); snow.gust(); 

Three layers of depth

Each flake gets a depth z between 0 and 1, picked with Math.random() ** 1.6 so there are more distant flakes than near ones. Near flakes are bigger, faster and more opaque; far ones are small and faint. Only flakes with z > 0.42 settle. The far ones keep falling "behind" the page, which is what makes it feel deep rather than flat.

A pile is just an array of heights

Every surface gets a Float32Array with one height per 4 px column. When a near flake crosses the top of a surface between two frames, it adds snow to that column and spreads some to its neighbours with a Gaussian falloff:

for (let k = -4; k <= 4; k++) { const edge = Math.min(j, n - 1 - j) * COL; // distance to the ledge edge const cap = max * clamp(edge / 18, 0.12, 1); // thinner near the edges p.cols[j] = Math.min(cap, p.cols[j] + amt * 0.25 * Math.exp(-(k * k) / 5)); } 

Every 0.2 s the pile relaxes (each column moves a little towards the average of its neighbours) so it forms soft mounds instead of spikes, and melts slowly with a half-life. The pile is drawn as one path with quadraticCurveTo through the column midpoints.

Landing on letters, not on the box

A heading's box includes empty line-height above the text, so snow "on the h1" would float in the air. For plain text elements I measure the first line of text with a Range and land the snow there, and only across the width of the text, not the empty space to its right:

const range = document.createRange(); range.selectNodeContents(el); const t = range.getClientRects()[0]; 

Cards, images and buttons use their box. The result is cached per element and recomputed when its width changes.

Brushing it off

The pointer's velocity is tracked. If it moves faster than 120 px/s through a pile, that part of the pile is removed and thrown back into the air as flakes moving in the direction of the swipe. The cursor also stirs falling flakes within 130 px. Both feel surprisingly physical for a few lines of code.

Visible on white pages

White snow on a white page is invisible. On light pages the flakes get a slightly cool tint and a soft blue-grey shadow, and piles get a thin cool edge. The page colour is checked every few seconds, so dark-mode switches are followed.

Everything is on one canvas with pointer-events: none, it pauses in hidden tabs, and prefers-reduced-motion gets far fewer, slower flakes without sway.

It's one of the free, MIT-licensed packages behind Fluri, my collection of interactive website effects. If you run WordPress, Shopify or Wix there's a no-code version with live settings.

What should settle on next: buttons, images, the navbar?

npm: https://www.npmjs.com/package/@fluritheme/falling-snow