Snow Globe
React + Tailwind
import type { CSSProperties } from 'react';
const T = 4.4;
const D = 148; // globe diameter
// Deterministic scatter so the flakes land in the same drifts every time.
let seed = 7;
const rand = () => ((seed = (seed * 16807) % 2147483647) / 2147483647);
const FLAKES = Array.from({ length: 30 }, () => {
const x0 = 16 + rand() * 116;
const y0 = 116 + Math.abs(x0 - 74) * -0.12 + rand() * 8;
const x1 = 14 + rand() * 120;
const y1 = 12 + rand() * 50;
return { x0, y0, x1, y1, x2: x1 + (rand() - 0.5) * 40, y2: y1 + 30 + rand() * 20, s: 2 + rand() * 1.8, d: rand() * 0.25 };
});
const px = (n: number) => `${n.toFixed(1)}px`;
const css = `
.loader-snow-globe { --water: light-dark(#dbdde1, #232529); --snow: light-dark(#fbfcfd, #f1f2f3); --house: light-dark(#6d7179, #7d8087); --roof: light-dark(#50535b, #393c41); --lamp: light-dark(#f3f4f7, #e5e6e9); --fir: light-dark(#50535b, #7d8087); --base: light-dark(#50535b, #393c41); position: relative; width: 200px; height: 194px; }
/* Shaken from the base: a hard rock either way, then still while it settles. */
.loader-snow-globe__whole { position: absolute; inset: 0; transform-origin: 100px 190px; animation: loader-snow-globe-shake ${T}s infinite; }
.loader-snow-globe__base { position: absolute; left: 30px; top: 138px; width: 140px; height: 50px; background: linear-gradient(90deg, color-mix(in oklab, var(--base) 75%, light-dark(#fbfcfd, #121417)), var(--base) 35%, color-mix(in oklab, var(--base) 75%, light-dark(#373a40, #f1f2f3)) 60%, color-mix(in oklab, var(--base) 80%, light-dark(#fbfcfd, #121417))); clip-path: polygon(10% 0, 90% 0, 100% 100%, 0 100%); border-radius: 0 0 6px 6px; }
.loader-snow-globe__plaque { position: absolute; left: 76px; top: 160px; width: 48px; height: 14px; border-radius: 2px; background: color-mix(in oklab, var(--base) 55%, light-dark(#373a40, #f1f2f3)); box-shadow: inset 0 0 0 1px color-mix(in oklab, light-dark(#fbfcfd, #121417) 30%, transparent); }
.loader-snow-globe__glass { position: absolute; left: 26px; top: 4px; width: ${D}px; height: ${D}px; border-radius: 50%; overflow: hidden; background: radial-gradient(circle at 50% 40%, color-mix(in oklab, var(--water) 80%, light-dark(#373a40, #f1f2f3)), var(--water) 70%); }
.loader-snow-globe__glass::after { content: ''; position: absolute; inset: 0; border-radius: 50%; box-shadow: inset 0 0 0 1.5px color-mix(in oklab, light-dark(#373a40, #f1f2f3) 30%, transparent), inset -10px -14px 22px color-mix(in oklab, light-dark(#fbfcfd, #121417) 30%, transparent); background: radial-gradient(ellipse 22% 12% at 30% 20%, color-mix(in oklab, var(--snow) 55%, transparent), transparent); }
/* The little scene: a drift of snow, a house with a lit window, a fir. */
.loader-snow-globe__drift { position: absolute; left: -10px; right: -10px; top: 112px; height: 60px; border-radius: 50% 50% 0 0 / 40% 40% 0 0; background: linear-gradient(var(--snow), color-mix(in oklab, var(--snow) 80%, var(--water))); }
.loader-snow-globe__house { position: absolute; left: 40px; top: 92px; width: 34px; height: 24px; background: var(--house); box-shadow: inset 0 0 0 1px color-mix(in oklab, light-dark(#fbfcfd, #121417) 25%, transparent); }
.loader-snow-globe__house::before { content: ''; position: absolute; left: -5px; right: -5px; top: -17px; height: 18px; background: var(--roof); clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.loader-snow-globe__house::after { content: ''; position: absolute; left: 7px; top: 7px; width: 7px; height: 7px; background: var(--lamp); box-shadow: 13px 4px 0 -1px var(--roof), 13px 8px 0 -1px var(--roof); }
.loader-snow-globe__fir { position: absolute; left: 88px; top: 70px; width: 26px; height: 46px; background: var(--fir); clip-path: polygon(50% 0, 78% 34%, 64% 34%, 92% 66%, 74% 66%, 100% 92%, 56% 92%, 56% 100%, 44% 100%, 44% 92%, 0 92%, 26% 66%, 8% 66%, 36% 34%, 22% 34%); }
.loader-snow-globe__flake { position: absolute; left: 0; top: 0; width: var(--s); height: var(--s); border-radius: 50%; background: var(--snow); transform: translate(var(--x0), var(--y0)); animation: loader-snow-globe-flake ${T}s infinite; animation-delay: var(--d); }
@keyframes loader-snow-globe-shake {
0% { transform: rotate(0deg); }
3% { transform: rotate(-10deg); }
6% { transform: rotate(8deg); }
9% { transform: rotate(-6deg); }
12% { transform: rotate(3.5deg); }
15% { transform: rotate(-1.2deg); }
18%, 100% { transform: rotate(0deg); }
}
@keyframes loader-snow-globe-flake {
0%, 3% { transform: translate(var(--x0), var(--y0)); animation-timing-function: cubic-bezier(0.1, 0.7, 0.3, 1); }
16% { transform: translate(var(--x1), var(--y1)); animation-timing-function: ease-in-out; }
42% { transform: translate(var(--x2), var(--y2)); animation-timing-function: ease-in-out; }
70% { transform: translate(calc((var(--x0) + var(--x2)) / 2 + 8px), calc((var(--y0) + var(--y2)) / 2)); animation-timing-function: ease-in-out; }
96%, 100% { transform: translate(var(--x0), var(--y0)); }
}
@media (prefers-reduced-motion: reduce) {
.loader-snow-globe *, .loader-snow-globe__whole { animation: none !important; }
.loader-snow-globe__flake:nth-child(3n) { transform: translate(var(--x2), var(--y2)); }
}
`;
export function Preview() {
return (
<>
<style href="kit-loaders-snow-globe" precedence="kit">
{css}
</style>
<div className="loader-snow-globe" role="status" aria-label="Loading">
<span className="loader-snow-globe__whole" aria-hidden="true">
<span className="loader-snow-globe__base" />
<span className="loader-snow-globe__plaque" />
<span className="loader-snow-globe__glass">
<span className="loader-snow-globe__drift" />
<span className="loader-snow-globe__house" />
<span className="loader-snow-globe__fir" />
{FLAKES.map((f, i) => (
<i
key={i}
className="loader-snow-globe__flake"
style={{ '--x0': px(f.x0), '--y0': px(f.y0), '--x1': px(f.x1), '--y1': px(f.y1), '--x2': px(f.x2), '--y2': px(f.y2), '--s': px(f.s), '--d': `${(-f.d).toFixed(2)}s` } as CSSProperties}
/>
))}
</span>
</span>
</div>
</>
);
}Markup where the component goes, CSS in your stylesheet. No JavaScript.
HTML
<div class="loader-snow-globe" role="status" aria-label="Loading">
<span class="loader-snow-globe__whole" aria-hidden="true">
<span class="loader-snow-globe__base"></span>
<span class="loader-snow-globe__plaque"></span>
<span class="loader-snow-globe__glass">
<span class="loader-snow-globe__drift"></span>
<span class="loader-snow-globe__house"></span>
<span class="loader-snow-globe__fir"></span>
<i class="loader-snow-globe__flake" style="--x0:16.0px;--y0:116.4px;--x1:48.7px;--y1:22.5px;--x2:57.9px;--y2:63.2px;--s:2.6px;--d:-0.19s"></i>
<i class="loader-snow-globe__flake" style="--x0:103.6px;--y0:116.8px;--x1:96.1px;--y1:43.8px;--x2:108.8px;--y2:78.6px;--s:2.7px;--d:-0.18s"></i>
<i class="loader-snow-globe__flake" style="--x0:97.0px;--y0:113.7px;--x1:96.1px;--y1:35.4px;--x2:113.0px;--y2:81.5px;--s:2.2px;--d:-0.13s"></i>
<i class="loader-snow-globe__flake" style="--x0:123.1px;--y0:115.6px;--x1:91.3px;--y1:40.9px;--x2:107.7px;--y2:89.0px;--s:2.7px;--d:-0.08s"></i>
<i class="loader-snow-globe__flake" style="--x0:113.1px;--y0:114.0px;--x1:32.3px;--y1:26.9px;--x2:29.4px;--y2:62.8px;--s:3.7px;--d:-0.14s"></i>
<i class="loader-snow-globe__flake" style="--x0:100.6px;--y0:119.8px;--x1:21.0px;--y1:25.7px;--x2:23.5px;--y2:65.9px;--s:2.8px;--d:-0.05s"></i>
<i class="loader-snow-globe__flake" style="--x0:121.4px;--y0:110.7px;--x1:57.9px;--y1:29.2px;--x2:64.4px;--y2:77.7px;--s:2.9px;--d:-0.04s"></i>
<i class="loader-snow-globe__flake" style="--x0:63.1px;--y0:117.0px;--x1:57.7px;--y1:33.2px;--x2:51.0px;--y2:73.8px;--s:3.1px;--d:-0.06s"></i>
<i class="loader-snow-globe__flake" style="--x0:121.2px;--y0:114.0px;--x1:117.6px;--y1:43.8px;--x2:122.9px;--y2:84.1px;--s:2.9px;--d:-0.17s"></i>
<i class="loader-snow-globe__flake" style="--x0:125.0px;--y0:113.1px;--x1:99.0px;--y1:24.6px;--x2:102.5px;--y2:61.6px;--s:2.6px;--d:-0.10s"></i>
<i class="loader-snow-globe__flake" style="--x0:108.2px;--y0:118.9px;--x1:27.3px;--y1:53.0px;--x2:10.4px;--y2:91.1px;--s:2.3px;--d:-0.02s"></i>
<i class="loader-snow-globe__flake" style="--x0:131.6px;--y0:110.9px;--x1:89.9px;--y1:19.2px;--x2:88.2px;--y2:61.1px;--s:2.2px;--d:-0.23s"></i>
<i class="loader-snow-globe__flake" style="--x0:118.6px;--y0:117.8px;--x1:120.2px;--y1:57.4px;--x2:130.7px;--y2:92.9px;--s:2.0px;--d:-0.06s"></i>
<i class="loader-snow-globe__flake" style="--x0:24.8px;--y0:110.1px;--x1:88.0px;--y1:23.6px;--x2:97.7px;--y2:63.4px;--s:3.2px;--d:-0.06s"></i>
<i class="loader-snow-globe__flake" style="--x0:118.3px;--y0:112.6px;--x1:58.9px;--y1:56.7px;--x2:43.6px;--y2:96.5px;--s:2.0px;--d:-0.23s"></i>
<i class="loader-snow-globe__flake" style="--x0:89.9px;--y0:121.5px;--x1:16.5px;--y1:57.0px;--x2:4.0px;--y2:106.4px;--s:3.0px;--d:-0.17s"></i>
<i class="loader-snow-globe__flake" style="--x0:46.9px;--y0:114.5px;--x1:39.1px;--y1:40.2px;--x2:21.2px;--y2:85.6px;--s:3.3px;--d:-0.18s"></i>
<i class="loader-snow-globe__flake" style="--x0:73.8px;--y0:116.2px;--x1:27.2px;--y1:58.0px;--x2:12.5px;--y2:101.7px;--s:3.6px;--d:-0.01s"></i>
<i class="loader-snow-globe__flake" style="--x0:118.4px;--y0:117.6px;--x1:133.1px;--y1:59.7px;--x2:143.7px;--y2:98.1px;--s:2.4px;--d:-0.18s"></i>
<i class="loader-snow-globe__flake" style="--x0:118.3px;--y0:113.9px;--x1:42.2px;--y1:32.2px;--x2:57.6px;--y2:73.4px;--s:2.6px;--d:-0.16s"></i>
<i class="loader-snow-globe__flake" style="--x0:101.2px;--y0:115.4px;--x1:101.0px;--y1:33.1px;--x2:89.0px;--y2:69.4px;--s:3.8px;--d:-0.25s"></i>
<i class="loader-snow-globe__flake" style="--x0:89.4px;--y0:121.1px;--x1:124.2px;--y1:22.0px;--x2:130.0px;--y2:54.7px;--s:2.9px;--d:-0.14s"></i>
<i class="loader-snow-globe__flake" style="--x0:105.5px;--y0:119.8px;--x1:71.8px;--y1:21.4px;--x2:69.7px;--y2:54.7px;--s:3.2px;--d:-0.13s"></i>
<i class="loader-snow-globe__flake" style="--x0:81.1px;--y0:119.2px;--x1:104.9px;--y1:30.1px;--x2:114.9px;--y2:60.6px;--s:2.5px;--d:-0.14s"></i>
<i class="loader-snow-globe__flake" style="--x0:39.5px;--y0:117.6px;--x1:48.9px;--y1:23.8px;--x2:55.3px;--y2:62.4px;--s:2.1px;--d:-0.19s"></i>
<i class="loader-snow-globe__flake" style="--x0:111.5px;--y0:118.8px;--x1:123.2px;--y1:46.0px;--x2:141.6px;--y2:76.5px;--s:3.4px;--d:-0.15s"></i>
<i class="loader-snow-globe__flake" style="--x0:100.0px;--y0:120.1px;--x1:18.4px;--y1:18.8px;--x2:1.7px;--y2:51.0px;--s:2.2px;--d:-0.00s"></i>
<i class="loader-snow-globe__flake" style="--x0:86.2px;--y0:122.1px;--x1:37.0px;--y1:18.7px;--x2:25.1px;--y2:62.2px;--s:2.4px;--d:-0.11s"></i>
<i class="loader-snow-globe__flake" style="--x0:131.3px;--y0:112.5px;--x1:94.9px;--y1:50.7px;--x2:90.7px;--y2:89.0px;--s:2.1px;--d:-0.06s"></i>
<i class="loader-snow-globe__flake" style="--x0:109.7px;--y0:119.5px;--x1:32.3px;--y1:58.3px;--x2:32.6px;--y2:90.7px;--s:2.4px;--d:-0.15s"></i>
</span>
</span>
</div>CSS
.loader-snow-globe { --water: light-dark(#dbdde1, #232529); --snow: light-dark(#fbfcfd, #f1f2f3); --house: light-dark(#6d7179, #7d8087); --roof: light-dark(#50535b, #393c41); --lamp: light-dark(#f3f4f7, #e5e6e9); --fir: light-dark(#50535b, #7d8087); --base: light-dark(#50535b, #393c41); position: relative; width: 200px; height: 194px; }
/* Shaken from the base: a hard rock either way, then still while it settles. */
.loader-snow-globe__whole { position: absolute; inset: 0; transform-origin: 100px 190px; animation: loader-snow-globe-shake 4.4s infinite; }
.loader-snow-globe__base { position: absolute; left: 30px; top: 138px; width: 140px; height: 50px; background: linear-gradient(90deg, color-mix(in oklab, var(--base) 75%, light-dark(#fbfcfd, #121417)), var(--base) 35%, color-mix(in oklab, var(--base) 75%, light-dark(#373a40, #f1f2f3)) 60%, color-mix(in oklab, var(--base) 80%, light-dark(#fbfcfd, #121417))); clip-path: polygon(10% 0, 90% 0, 100% 100%, 0 100%); border-radius: 0 0 6px 6px; }
.loader-snow-globe__plaque { position: absolute; left: 76px; top: 160px; width: 48px; height: 14px; border-radius: 2px; background: color-mix(in oklab, var(--base) 55%, light-dark(#373a40, #f1f2f3)); box-shadow: inset 0 0 0 1px color-mix(in oklab, light-dark(#fbfcfd, #121417) 30%, transparent); }
.loader-snow-globe__glass { position: absolute; left: 26px; top: 4px; width: 148px; height: 148px; border-radius: 50%; overflow: hidden; background: radial-gradient(circle at 50% 40%, color-mix(in oklab, var(--water) 80%, light-dark(#373a40, #f1f2f3)), var(--water) 70%); }
.loader-snow-globe__glass::after { content: ''; position: absolute; inset: 0; border-radius: 50%; box-shadow: inset 0 0 0 1.5px color-mix(in oklab, light-dark(#373a40, #f1f2f3) 30%, transparent), inset -10px -14px 22px color-mix(in oklab, light-dark(#fbfcfd, #121417) 30%, transparent); background: radial-gradient(ellipse 22% 12% at 30% 20%, color-mix(in oklab, var(--snow) 55%, transparent), transparent); }
/* The little scene: a drift of snow, a house with a lit window, a fir. */
.loader-snow-globe__drift { position: absolute; left: -10px; right: -10px; top: 112px; height: 60px; border-radius: 50% 50% 0 0 / 40% 40% 0 0; background: linear-gradient(var(--snow), color-mix(in oklab, var(--snow) 80%, var(--water))); }
.loader-snow-globe__house { position: absolute; left: 40px; top: 92px; width: 34px; height: 24px; background: var(--house); box-shadow: inset 0 0 0 1px color-mix(in oklab, light-dark(#fbfcfd, #121417) 25%, transparent); }
.loader-snow-globe__house::before { content: ''; position: absolute; left: -5px; right: -5px; top: -17px; height: 18px; background: var(--roof); clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.loader-snow-globe__house::after { content: ''; position: absolute; left: 7px; top: 7px; width: 7px; height: 7px; background: var(--lamp); box-shadow: 13px 4px 0 -1px var(--roof), 13px 8px 0 -1px var(--roof); }
.loader-snow-globe__fir { position: absolute; left: 88px; top: 70px; width: 26px; height: 46px; background: var(--fir); clip-path: polygon(50% 0, 78% 34%, 64% 34%, 92% 66%, 74% 66%, 100% 92%, 56% 92%, 56% 100%, 44% 100%, 44% 92%, 0 92%, 26% 66%, 8% 66%, 36% 34%, 22% 34%); }
.loader-snow-globe__flake { position: absolute; left: 0; top: 0; width: var(--s); height: var(--s); border-radius: 50%; background: var(--snow); transform: translate(var(--x0), var(--y0)); animation: loader-snow-globe-flake 4.4s infinite; animation-delay: var(--d); }
@keyframes loader-snow-globe-shake {
0% { transform: rotate(0deg); }
3% { transform: rotate(-10deg); }
6% { transform: rotate(8deg); }
9% { transform: rotate(-6deg); }
12% { transform: rotate(3.5deg); }
15% { transform: rotate(-1.2deg); }
18%, 100% { transform: rotate(0deg); }
}
@keyframes loader-snow-globe-flake {
0%, 3% { transform: translate(var(--x0), var(--y0)); animation-timing-function: cubic-bezier(0.1, 0.7, 0.3, 1); }
16% { transform: translate(var(--x1), var(--y1)); animation-timing-function: ease-in-out; }
42% { transform: translate(var(--x2), var(--y2)); animation-timing-function: ease-in-out; }
70% { transform: translate(calc((var(--x0) + var(--x2)) / 2 + 8px), calc((var(--y0) + var(--y2)) / 2)); animation-timing-function: ease-in-out; }
96%, 100% { transform: translate(var(--x0), var(--y0)); }
}
@media (prefers-reduced-motion: reduce) {
.loader-snow-globe *, .loader-snow-globe__whole { animation: none !important; }
.loader-snow-globe__flake:nth-child(3n) { transform: translate(var(--x2), var(--y2)); }
}Goal: Create a "Snow Globe" loader.
Visual behavior: A snow globe gets a shake: the flakes swirl up round the little house and drift slowly back down to settle.
Technique:
- Pure CSS: every motion is a keyframe animation, so the plain HTML version needs no script.
- The globe rocks hard either way from its base, then stands still while the snow settles.
- Thirty flakes each carry their own resting, swirling and drifting positions as variables, scattered from a seeded random so they land the same way every time.
- One keyframe moves every flake through its own positions: thrown up by the shake, swirled, then drifting down to the drift.
Accessibility: The root has role="status" and aria-label="Loading"; everything inside it is aria-hidden. Under prefers-reduced-motion the snow lies settled with a few flakes still falling.
My stack: {{USER_STACK}}
My styling: {{USER_STYLING}}
My constraints: {{USER_CONSTRAINTS}}
My colors: neutral only. Black, white and grays, no hues. Use the color values above as written, or my project's closest neutral tokens.
Return a single self-contained component. No dependencies.Goal: Create a "Snow Globe" loader.
Visual behavior: A snow globe gets a shake: the flakes swirl up round the little house and drift slowly back down to settle.
Technique:
- Pure CSS: every motion is a keyframe animation, so the plain HTML version needs no script.
- The globe rocks hard either way from its base, then stands still while the snow settles.
- Thirty flakes each carry their own resting, swirling and drifting positions as variables, scattered from a seeded random so they land the same way every time.
- One keyframe moves every flake through its own positions: thrown up by the shake, swirled, then drifting down to the drift.
Accessibility: The root has role="status" and aria-label="Loading"; everything inside it is aria-hidden. Under prefers-reduced-motion the snow lies settled with a few flakes still falling.
My stack: {{USER_STACK}}
My styling: {{USER_STYLING}}
My constraints: {{USER_CONSTRAINTS}}
My colors: use my project's existing color tokens. The color values above are grayscale placeholders. Map each one by its role (surface, text, border, accent, glow) to my theme, and keep their relative lightness so contrast and the effect still read.
Return a single self-contained component. No dependencies.Paste into Claude, ChatGPT or Cursor after filling in {{USER_STACK}}, {{USER_STYLING}} and {{USER_CONSTRAINTS}}. Neutral keeps the greys you see here; Match my project asks the model to map them onto your own colour tokens.
Free to use in any project, commercial included. MIT-0, no attribution required. Licence
About this component
A snow globe gets a shake: the flakes swirl up round the little house and drift slowly back down to settle.
- Dependencies
- None
- Difficulty
- Intermediate
- Triggers
- continuous, loop, delay stagger
- Techniques
- keyframes, css variables, radial gradient
- Reduced motion
- Respected
- Theme
- Light and dark (follows your page's color-scheme)
The root has role="status" and aria-label="Loading"; everything inside it is aria-hidden. Under prefers-reduced-motion the snow lies settled with a few flakes still falling.