Skip to content
WANCRAFT

E.202Backgrounds & Effects

Weather Effect

Rain, snow or sleet over content: wind-angled streaks that splash, drifting flakes with sway and depth, and a pointer gust.

NewReactCanvasTailwindintermediate

Overview

Weather Effect lays precipitation over any container. Rain falls as streaks that lean with the wind, drawn in three depth buckets (far drops thin and faint), and the nearer drops land on a shallow ground band at the bottom with a flat ring and a few droplets that arc up and fall back. Snow drifts down in layers — near flakes bigger, faster and brighter — with a gentle individual sway; sleet mixes short streaks with ice pellets that bounce. Moving a mouse or pen pointer pushes nearby particles in a soft gust, flakes more than drops. The particle count scales with the container's area and drops on narrow screens, motion runs on fixed 60Hz steps, the canvas is DPR-aware and pauses offscreen and in hidden tabs, and reduced motion draws a still frame.

01Installation

Method 01 · Registry

CLI verified

Uses the shadcn CLI in a project initialised with shadcn init. Installs the file to components/ui/weather-effect.tsx and adds its dependencies.

npx shadcn@latest add https://wancraft.my/r/weather-effect.json

Method 02 · Copy and paste

  1. 1. No extra dependencies — React and Tailwind CSS only.
  2. 2. Copy the source from the Code tab into components/ui/weather-effect.tsx.
  3. 3. Import it and adjust props.
Dependencies
None
Peer
react ≥ 18, tailwindcss ≥ 4
Added
13 Oct 2026
Updated
—

02Usage

The default configuration. Change properties above to generate a tailored example in the Usage tab.

example.tsx
import { WeatherEffect } from "@/components/ui/weather-effect";

export function WeatherEffectExample() {
  return (
    <div className="relative h-80 w-full overflow-hidden rounded-xl">
      <WeatherEffect />
    </div>
  );
}

03Props

PropTypeDefaultDescription
type"rain" | "snow" | "sleet""rain"Rain streaks, drifting snow, or sleet (short streaks plus bouncing ice pellets).
intensitynumber0.5Density, 0.1–1; scales with the container's area (×0.7 under 640px wide, max 1,100 particles).
windnumber0.25Wind from -1 (blowing left) to 1 (blowing right); flakes drift more than drops.
speednumber1Fall speed multiplier.
gustbooleantrueA moving mouse or pen pointer pushes particles within 200px (touch: while pressed).
splashbooleantrueNear raindrops ring and spray at the bottom edge; pellets bounce.
childrenReactNode—Optional content layered above the weather.
...propsHTMLAttributes<HTMLDivElement>—Forwarded to the root, which is absolute inset-0 — place it inside a positioned parent.

04Features

  • 01Rain streaks angled by the wind, batched into three depth buckets
  • 02Splash rings and droplets on a shallow ground band; sleet pellets bounce
  • 03Snow in layers with per-flake sway; soft flake sprite rendered once per theme
  • 04Gentle pointer gust that pushes nearby particles along
  • 05Adaptive count from the container's area, lighter on narrow screens
  • 06Fixed 60Hz steps, DPR-aware canvas (capped at 2), ResizeObserver, pauses offscreen and in hidden tabs
motion · continuousinput · pointerinput · viewport

05Accessibility

  • The canvas is aria-hidden and ignores pointer events; layered content stays fully interactive.
  • prefers-reduced-motion draws a single still frame of the weather — no falling, sway or gust.
  • Particles are drawn at low opacity in the theme's text colour so overlaid text stays readable in both themes.

06Limitations

  • Decorative only — the weather conveys no information and has no keyboard interaction.