Zach’s ugly mug (his face) Zach Leat­herman

<snow-fall> Web Component

A snowy landscape with a variety of evergreen trees behind a small lake.
December 15, 2023
🚾Web Component@zachleat/snow-fall

A web component to add snow to your web site (or to an element on your web site).

All🚾 0.8%
Popularity
npm31k Monthly downloads for @zachleat/snow-fall: start 1k, high 2k, low 679, end 800 cdn (12mo)3k Monthly jsDelivr CDN hits for @zachleat/snow-fall: start 128, high 961, low 28, end 249
Versions
4 versions in
1.0.3
Audit
0 reports
0 deps
Issues
4
PRs
0

<snow-fall> is a zero-dependency, JavaScript web component to add snow to your web site (or to an element on your web site). This is a web component implementation of this Codepen from alphardex.

Usage

<script type="module" src="snow-fall.js"></script>

<!-- Add snow to the page -->
<snow-fall></snow-fall>

<!-- Add snow to the first child element -->
<snow-fall>
	<div style="width: 300px; height: 300px">
</snow-fall>

Installable from npm:

npm install @zachleat/snow-fall

Use with <is-land>

This is best used with <is-land> to respect user preferences for reduced motion:

<is-land on:media="(prefers-reduced-motion: no-preference)">
	<snow-fall></snow-fall>
</is-land>

Change the snow color

<!-- Change snow color -->
<snow-fall style="--snow-fall-color: rebeccapurple"></snow-fall>

Change the number of snowflakes

<!-- Default: 100 -->
<snow-fall count="200"></snow-fall>

Change the size of the snowflakes

Added in v1.0.2

<!-- Default: 10px -->
<snow-fall style="--snow-fall-size: 20px"></snow-fall>

Force the rendering mode (page/element)

You probably don’t need this.

<snow-fall mode="page"></snow-fall>
<snow-fall mode="element"></snow-fall>

IndieWeb Avatar for https://unsplash.com/Poster image by Adam Chang

Zach Leatherman is a builder for the web at Font Awesome and the creator of Build Awesome (née Eleventy/11ty), an award-winning open source website generator. He measures website performance with speedlify and at one point became too fixated on web fonts. He has given 86 talks in nine different countries at events like Beyond Tellerrand, State of the Browser, Smashing Conference, Jamstack Conf, CSSConf, and The White House. Learn more about Zach »