Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Backgrounds

Pro

Snow Background for React

Snow falling over a soft winter sky, with near flakes that sway and a far layer that drifts behind them. For React with Base UI, when a seasonal page or a winter hero should feel cold and calm.

Framework

Snow falls over a soft winter sky. Near flakes are bigger, brighter and faster and sway as they fall; a far layer of tiny flakes drifts behind them, so the snowfall has depth. The flakes are laid out from their index when the page renders and moved by keyframes the install adds to your stylesheet, so no JavaScript runs while it snows.

Use it for a seasonal launch, a holiday card or a winter hero. For fast streaks and optional lightning use Rain; for golden motes drifting through a shaft of sunlight, Pollen; for the same fall in colour, Confetti.

Preview width

Installation

Part of Pro
Pro unlocks the code and one-line install of every Pro button and text effect, plus the MCP for your AI editor.
Have Pro already? Sign in to open it.Opens here as soon as you're Pro.

Usage

import { Snow } from "@/components/ui/snow";
<Snow className="min-h-[420px]">
  <h1>Let it snow</h1>
</Snow>

Snow is a container: put your content inside and the snow falls behind it. It fills the box you give it, so set its height (min-h-[420px]), or className="fixed inset-0 -z-10" to cover the whole page.

Demos

Night sky

skyColor sets the top of the sky; toward the ground it takes a faint haze of the flakes' colour. A dark blue sky with white flakes stays the same night in light and dark mode.

Preview width

Blizzard

count is how many near flakes fall at once (80, up to 150), wind how far a flake drifts sideways for each height it falls, and speed multiplies every fall. Together they turn a quiet snowfall into a storm.

Preview width

Accessibility

The snow is decoration: the whole layer is hidden from screen readers and ignores the pointer, and your content inside reads as usual. With reduced motion every flake stops where it is, so the box shows a still snowfield on its sky rather than an empty one. Nothing flashes.

In light mode the default sky is an overcast grey, so white flakes show. Text in the foreground colour stays above 10:1 on it, but muted text falls under 3:1 near the top: keep body text in text-foreground, or set skyColor to a lighter or darker sky.

FAQ

How does the depth work?

Each near flake's depth comes from its index and sets its size, brightness, speed and sway. Behind them, two far layers of tiny flakes are repeating SVG patterns that drift down slowly, the nearer one a little faster.

Can I add wind?

wind is how far a flake moves sideways for each height it falls: 0.15 (the default) is 15%, a negative number blows left and 0 falls straight down. The far layers lean to match.

How do I make it heavier or lighter?

count sets the near flakes (80 by default, up to 150) and speed scales every fall. For a blizzard try count={150} wind={0.4} speed={1.6}; for a few slow flakes, count={30} speed={0.6}.

Does it work in light mode?

Yes: it paints an overcast grey sky so white flakes show. Set skyColor="transparent" to snow over your own background, and flakeColor if that background is light.

Is the speed the same in a small card?

Yes: flakes fall at a set number of pixels per second, so a card and a full page snow at the same pace, and a short card is crossed sooner. Lower speed for a calmer card.

Does it respect reduced motion?

Yes: the flakes stop where they are and the sky stays. Nothing flashes.

Does it slow the page down?

No script runs: the flakes are placed when the page renders and the browser's compositor moves them, off the main thread. When the snow scrolls out of view the browser skips it. count stops at 150 because each near flake is one more layer for the compositor to move.

API Reference

Snow

<div> data-slot="snow"

PropType
count?number

How many near flakes fall at once, from 0 to 150. The far flakes are a repeating pattern behind them, so they fill any size of box.

Default
80
flakeColor?string

The flakes' colour, any CSS colour.

Default
"var(--background)" in light mode, "var(--foreground)" in dark
skyColor?string

The colour at the top of the sky, any CSS colour; toward the ground it takes a faint haze of the flakes' colour. "transparent" drops it, to snow over a photo or your own background.

Default
an overcast grey in light mode, the page's background in dark
speed?number

How fast it falls, as a multiplier: 0.5 is slow, 2 is a flurry. @default 1.

wind?number

How far a flake drifts sideways for each height it falls: 0.15 is 15%, a negative number blows left, 0 falls straight down.

Default
0.15
render?ReactElement | ((props: object, state: object) => ReactElement)

Replace the host element or compose it with another component.

Type
ReactElement | ((props: object, state: object) => ReactElement)
className?string

Merged with the part's classes.

CSS variableType
--snow-colorstring

The flakes' colour (--background in light mode, --foreground in dark).

--snow-groundstring

The bottom of the sky (the sky with a 12% haze of the flakes' colour).

--snow-skystring

The top of the sky (an overcast grey in light mode, --background in dark).

--snow-speedstring

How fast it falls, a multiplier (1).

--snow-windstring

Sideways drift per height fallen (0.15).

All 100 backgrounds