# Snowfall with depth

> Three layers of snowflakes fall at different speeds and blur levels, so the scene feels deep.

- Category: [Backgrounds](https://library.aimran.es/components/patterns)
- Built with: HTML + CSS
- Live editor: https://library.aimran.es/blocks/pt-snow
- Library: AIMRAN Library (https://library.aimran.es), free, no sign-up, by Aimran Oukham

## Where to use it

Falling snow is the obvious choice for seasonal pages: a Christmas sale on an online shop, the booking page of a ski chalet or the landing page of a winter newsletter. Because the near flakes fall faster and look out of focus, the background has real depth instead of looking like flat confetti. An animated CSS snow background, no JavaScript.

Take it down once the season is over, since snow in March just looks forgotten. On a product page, lower the opacity so the flakes don’t cross the photos too visibly, and let a dark blue background do most of the work.

## Code

### HTML

```html
<div class="pt-snow"><i></i><i></i><i></i></div>
```

### CSS

```css
.pt-snow {
  --c1: #0071e3;
  --c2: #c4b5fd;
  --c3: #ffffff;
  --k: 1;
  /* velocidad */
  --d: 1;
  /* densidad / escala */
  --o: 1;
  /* opacidad */
  --bg: #05060a;
  --fg: #ffffff;
  --blend: screen;
  min-height: 100vh;
}

.pt-snow {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg);
  container-type: size;
  isolation: isolate;
}

.pt-snow>* {
  opacity: var(--o);
}

.pt-snow {
  background: radial-gradient(ellipse at 50% 0%,color-mix(in srgb,var(--c1) 35%,var(--bg)),var(--bg) 70%)!important;
}

.pt-snow i {
  position: absolute;
  inset: -10%;
  background-image: radial-gradient(circle at 15% 20%,color-mix(in srgb,var(--c3) 55%,var(--fg)) var(--r),transparent calc(var(--r) + 1px)),radial-gradient(circle at 65% 55%,color-mix(in srgb,var(--c3) 55%,var(--fg)) var(--r),transparent calc(var(--r) + 1px)),radial-gradient(circle at 40% 85%,color-mix(in srgb,var(--c3) 55%,var(--fg)) var(--r),transparent calc(var(--r) + 1px)),radial-gradient(circle at 85% 10%,color-mix(in srgb,var(--c2) 70%,var(--fg)) var(--r),transparent calc(var(--r) + 1px));
  background-size: var(--sz) var(--sz);
  animation: pt-snow-f calc(var(--t) / var(--k)) linear infinite,pt-snow-s calc(var(--t) * .6 / var(--k)) ease-in-out infinite alternate;
}

.pt-snow i:nth-child(1) {
  --sz: calc(90px * var(--d));
  --r: 1.2px;
  --t: 9s;
}

.pt-snow i:nth-child(2) {
  --sz: calc(160px * var(--d));
  --r: 2.2px;
  --t: 14s;
  filter: blur(1px);
}

.pt-snow i:nth-child(3) {
  --sz: calc(270px * var(--d));
  --r: 4px;
  --t: 20s;
  filter: blur(3px);
}

@keyframes pt-snow-f {
  to {
    background-position: 0 var(--sz);
  }
}

@keyframes pt-snow-s {
  from {
    transform: translateX(-2%);
  }
  to {
    transform: translateX(2%);
  }
}
```

### React

```tsx
// @ts-nocheck
import { useEffect, useRef } from "react";

const css = `
.pt-snow {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg);
  container-type: size;
  isolation: isolate;
}

.pt-snow>* {
  opacity: var(--o);
}

.pt-snow {
  background: radial-gradient(ellipse at 50% 0%,color-mix(in srgb,var(--c1) 35%,var(--bg)),var(--bg) 70%)!important;
}

.pt-snow i {
  position: absolute;
  inset: -10%;
  background-image: radial-gradient(circle at 15% 20%,color-mix(in srgb,var(--c3) 55%,var(--fg)) var(--r),transparent calc(var(--r) + 1px)),radial-gradient(circle at 65% 55%,color-mix(in srgb,var(--c3) 55%,var(--fg)) var(--r),transparent calc(var(--r) + 1px)),radial-gradient(circle at 40% 85%,color-mix(in srgb,var(--c3) 55%,var(--fg)) var(--r),transparent calc(var(--r) + 1px)),radial-gradient(circle at 85% 10%,color-mix(in srgb,var(--c2) 70%,var(--fg)) var(--r),transparent calc(var(--r) + 1px));
  background-size: var(--sz) var(--sz);
  animation: pt-snow-f calc(var(--t) / var(--k)) linear infinite,pt-snow-s calc(var(--t) * .6 / var(--k)) ease-in-out infinite alternate;
}

.pt-snow i:nth-child(1) {
  --sz: calc(90px * var(--d));
  --r: 1.2px;
  --t: 9s;
}

.pt-snow i:nth-child(2) {
  --sz: calc(160px * var(--d));
  --r: 2.2px;
  --t: 14s;
  filter: blur(1px);
}

.pt-snow i:nth-child(3) {
  --sz: calc(270px * var(--d));
  --r: 4px;
  --t: 20s;
  filter: blur(3px);
}

@keyframes pt-snow-f {
  to {
    background-position: 0 var(--sz);
  }
}

@keyframes pt-snow-s {
  from {
    transform: translateX(-2%);
  }
  to {
    transform: translateX(2%);
  }
}

`;

export default function PatternSnow() {
  const ref = useRef(null);
  return (
    <>
      <style>{css}</style>
      <div
        ref={ref}
        className="pt-snow"
        style={{
          "--c1": "#0071e3",
          "--c2": "#c4b5fd",
          "--c3": "#ffffff",
          "--k": 1,
          "--d": 1,
          "--o": 1,
          "--bg": "#05060a",
          "--fg": "#ffffff",
          "--blend": "screen",
          minHeight: "100vh",
        }}
      >
        <i></i><i></i><i></i>
      </div>
    </>
  );
}
```

## Prompt for AI assistants

Paste this into ChatGPT, Claude, Cursor, v0 or Lovable to adapt the block to your stack (Tailwind, Vue, Svelte…):

````text
I want to add the “Snowfall with depth” block (Backgrounds) from AIMRAN Library to my project.

## What it is
Three layers of snowflakes fall at different speeds and blur levels, so the scene feels deep.

## Chosen settings
- Color 1: #0071e3
- Color 2: #c4b5fd
- Color 3: #ffffff
- Speed: 1x (from 0.2 to 3x)
- Density / scale: 1x (from 0.5 to 2x)
- Opacity: 1 (from 0.2 to 1)

## What I need
1. Add it to my project with the same look and animation as the reference code: same sizes, colours, radii, shadows, timings and easing.
2. It is built with plain HTML and CSS (the reference wraps it in a React component with its CSS). If my project uses something else (Vue, Svelte, Astro, plain HTML…), translate it without losing any behaviour. If I use Tailwind, turn the styles into classes; if not, keep the CSS in its own file.
3. Expose the settings above as props (or CSS variables) with those values as defaults.
4. Make it work well on phones: nothing that depends only on hover, touch targets of at least 44 px and no overflow on 320 px screens.
5. Make it look right in light and dark mode.
6. Keep it accessible: semantic HTML, roles and aria-* where needed, visible focus and keyboard support.
7. Respect prefers-reduced-motion: with reduced motion, no big animations but the same end result.

## Reference code
```tsx
// @ts-nocheck
import { useEffect, useRef } from "react";

const css = `
.pt-snow {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg);
  container-type: size;
  isolation: isolate;
}

.pt-snow>* {
  opacity: var(--o);
}

.pt-snow {
  background: radial-gradient(ellipse at 50% 0%,color-mix(in srgb,var(--c1) 35%,var(--bg)),var(--bg) 70%)!important;
}

.pt-snow i {
  position: absolute;
  inset: -10%;
  background-image: radial-gradient(circle at 15% 20%,color-mix(in srgb,var(--c3) 55%,var(--fg)) var(--r),transparent calc(var(--r) + 1px)),radial-gradient(circle at 65% 55%,color-mix(in srgb,var(--c3) 55%,var(--fg)) var(--r),transparent calc(var(--r) + 1px)),radial-gradient(circle at 40% 85%,color-mix(in srgb,var(--c3) 55%,var(--fg)) var(--r),transparent calc(var(--r) + 1px)),radial-gradient(circle at 85% 10%,color-mix(in srgb,var(--c2) 70%,var(--fg)) var(--r),transparent calc(var(--r) + 1px));
  background-size: var(--sz) var(--sz);
  animation: pt-snow-f calc(var(--t) / var(--k)) linear infinite,pt-snow-s calc(var(--t) * .6 / var(--k)) ease-in-out infinite alternate;
}

.pt-snow i:nth-child(1) {
  --sz: calc(90px * var(--d));
  --r: 1.2px;
  --t: 9s;
}

.pt-snow i:nth-child(2) {
  --sz: calc(160px * var(--d));
  --r: 2.2px;
  --t: 14s;
  filter: blur(1px);
}

.pt-snow i:nth-child(3) {
  --sz: calc(270px * var(--d));
  --r: 4px;
  --t: 20s;
  filter: blur(3px);
}

@keyframes pt-snow-f {
  to {
    background-position: 0 var(--sz);
  }
}

@keyframes pt-snow-s {
  from {
    transform: translateX(-2%);
  }
  to {
    transform: translateX(2%);
  }
}

`;

export default function PatternSnow() {
  const ref = useRef(null);
  return (
    <>
      <style>{css}</style>
      <div
        ref={ref}
        className="pt-snow"
        style={{
          "--c1": "#0071e3",
          "--c2": "#c4b5fd",
          "--c3": "#ffffff",
          "--k": 1,
          "--d": 1,
          "--o": 1,
          "--bg": "#05060a",
          "--fg": "#ffffff",
          "--blend": "screen",
          minHeight: "100vh",
        }}
      >
        <i></i><i></i><i></i>
      </div>
    </>
  );
}
```

Give me the complete final code, ready to paste, and tell me in one line where to put it in my project.
````
