Aurora background
Three huge blurred lights drift slowly behind your content under a layer of film grain. Works on dark and light bases.
"use client";
import { useEffect, useRef, type CSSProperties, type ReactNode } from "react";
import "./aurora.css";
type AuroraProps = {
children?: ReactNode;
/** Three colors for the three drifting lights, back to front. */
colors?: [string, string, string];
/** The color underneath. */
base?: string;
/** "screen" for dark bases (lights add up), "multiply" for light bases (inks add up). */
blend?: "screen" | "multiply";
/** 1 is calm. 2 is twice as fast. */
speed?: number;
className?: string;
style?: CSSProperties;
};
/**
* Aurora
* Three huge blurred lights drift slowly behind your content, with a layer
* of film grain on top so the gradients never band. Pure CSS animation;
* it pauses itself while it is off screen.
*/
export function Aurora({
children,
colors = ["#2b35ff", "#ff5a1f", "#d7ff3a"],
base = "#0e0e10",
blend = "screen",
speed = 1,
className = "",
style,
}: AuroraProps) {
const ref = useRef<HTMLDivElement>(null);
useEffect(() => {
const el = ref.current;
if (!el) return;
const io = new IntersectionObserver(([e]) => {
el.dataset.paused = String(!e.isIntersecting);
});
io.observe(el);
return () => io.disconnect();
}, []);
const vars = {
"--a1": colors[0],
"--a2": colors[1],
"--a3": colors[2],
"--base": base,
"--speed": speed,
"--blend": blend,
...style,
} as CSSProperties;
return (
<div ref={ref} className={`gu-aurora ${className}`} style={vars}>
<div className="gu-aurora__lights" aria-hidden="true">
<span />
<span />
<span />
</div>
<div className="gu-aurora__grain" aria-hidden="true" />
<div className="gu-aurora__content">{children}</div>
</div>
);
}
Paste this into ChatGPT, Claude, Cursor, v0, Lovable or Bolt. It describes the layout, motion, colors and accessibility and includes the code, so the AI can rebuild it in any framework.
# Build this UI piece: Aurora background
You are a senior front-end engineer. Recreate the piece below in my project. If I don't say which framework I use, ask once, then build it in that framework (React, Vue, Svelte, Angular, Astro, plain HTML/CSS/JS or anything else). Keep the behavior, motion, colors, spacing and accessibility exactly as described. Keep the code clean and commented for beginners.
## What it is
A background of three huge blurred lights drifting slowly behind your content, with a layer of film grain on top so the gradients never band. It works on dark bases (lights add up) and light bases (inks add up).
## Behavior and motion
- Pure CSS animation. Three circles with radial gradients sit in a layer 20% bigger than the box, blurred 70px.
- Each light has its own path and period so the mix never visibly repeats: 19s, 23s and 29s (divided by `speed`), ease-in-out, alternate, infinite. They move by translate and scale only.
- An IntersectionObserver pauses the animations (animation-play-state) while the box is off screen.
## Look
- Lights use mix-blend-mode from the `blend` prop: screen on dark bases, multiply on light ones.
- Grain: an SVG feTurbulence noise tile (fractalNoise, baseFrequency 0.9) at 22% opacity with mix-blend-mode: overlay.
- Defaults: base ink #0e0e10, lights ultramarine #2b35ff, orange #ff5a1f and lime #d7ff3a (the third light is smaller and at 55% opacity). Light-mode demo: cream base, orange, soft peach #ffb38f and ultramarine, multiplied.
- Demo content: a radio station hero, "Music for after midnight." in 4.8rem type with a short line below.
## Accessibility
- The lights and grain are aria-hidden and sit behind the content (isolation: isolate, negative z-index).
- Check your text contrast against the brightest point of the lights.
- prefers-reduced-motion: the lights stay still. The colors and grain remain.
## Props
children, colors ([string, string, string]), base, blend ("screen" | "multiply"), speed, className, style.
## Reference implementation
The original is written in React with one plain CSS file. Dependencies: none (plain React and CSS). Translate it faithfully; do not add new libraries unless my framework needs them.
### Aurora.tsx
```tsx
"use client";
import { useEffect, useRef, type CSSProperties, type ReactNode } from "react";
import "./aurora.css";
type AuroraProps = {
children?: ReactNode;
/** Three colors for the three drifting lights, back to front. */
colors?: [string, string, string];
/** The color underneath. */
base?: string;
/** "screen" for dark bases (lights add up), "multiply" for light bases (inks add up). */
blend?: "screen" | "multiply";
/** 1 is calm. 2 is twice as fast. */
speed?: number;
className?: string;
style?: CSSProperties;
};
/**
* Aurora
* Three huge blurred lights drift slowly behind your content, with a layer
* of film grain on top so the gradients never band. Pure CSS animation;
* it pauses itself while it is off screen.
*/
export function Aurora({
children,
colors = ["#2b35ff", "#ff5a1f", "#d7ff3a"],
base = "#0e0e10",
blend = "screen",
speed = 1,
className = "",
style,
}: AuroraProps) {
const ref = useRef<HTMLDivElement>(null);
useEffect(() => {
const el = ref.current;
if (!el) return;
const io = new IntersectionObserver(([e]) => {
el.dataset.paused = String(!e.isIntersecting);
});
io.observe(el);
return () => io.disconnect();
}, []);
const vars = {
"--a1": colors[0],
"--a2": colors[1],
"--a3": colors[2],
"--base": base,
"--speed": speed,
"--blend": blend,
...style,
} as CSSProperties;
return (
<div ref={ref} className={`gu-aurora ${className}`} style={vars}>
<div className="gu-aurora__lights" aria-hidden="true">
<span />
<span />
<span />
</div>
<div className="gu-aurora__grain" aria-hidden="true" />
<div className="gu-aurora__content">{children}</div>
</div>
);
}
```
### aurora.css
```css
.gu-aurora {
position: relative;
isolation: isolate;
overflow: hidden;
background: var(--base);
}
.gu-aurora__lights {
position: absolute;
inset: -20%;
z-index: -2;
filter: blur(70px) saturate(1.15);
}
.gu-aurora__lights span {
position: absolute;
width: 60%;
aspect-ratio: 1;
border-radius: 50%;
mix-blend-mode: var(--blend, screen);
animation-timing-function: ease-in-out;
animation-iteration-count: infinite;
animation-direction: alternate;
}
/* Each light has its own path and its own period, so the mix never repeats exactly. */
.gu-aurora__lights span:nth-child(1) {
left: -5%;
top: 0;
background: radial-gradient(circle, var(--a1) 0%, transparent 65%);
animation-name: gu-aurora-one;
animation-duration: calc(19s / var(--speed));
}
.gu-aurora__lights span:nth-child(2) {
right: -10%;
top: 15%;
background: radial-gradient(circle, var(--a2) 0%, transparent 62%);
animation-name: gu-aurora-two;
animation-duration: calc(23s / var(--speed));
}
.gu-aurora__lights span:nth-child(3) {
left: 25%;
bottom: -15%;
width: 42%;
opacity: 0.55;
background: radial-gradient(circle, var(--a3) 0%, transparent 60%);
animation-name: gu-aurora-three;
animation-duration: calc(29s / var(--speed));
}
@keyframes gu-aurora-one {
to {
transform: translate(35%, 25%) scale(1.25);
}
}
@keyframes gu-aurora-two {
to {
transform: translate(-40%, 10%) scale(0.85);
}
}
@keyframes gu-aurora-three {
to {
transform: translate(30%, -45%) scale(1.4);
}
}
.gu-aurora[data-paused="true"] .gu-aurora__lights span {
animation-play-state: paused;
}
/* Film grain from an SVG noise filter. It also hides gradient banding. */
.gu-aurora__grain {
position: absolute;
inset: 0;
z-index: -1;
opacity: 0.22;
mix-blend-mode: overlay;
pointer-events: none;
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
.gu-aurora__content {
position: relative;
}
/* Reduced motion: the lights stay where they are. The colors remain. */
@media (prefers-reduced-motion: reduce) {
.gu-aurora__lights span {
animation: none;
}
}
```
You might also want
Next piece: Avatar stackGrid with light beams
Animations, intermediate
Dot ripple field
Animations, intermediate
Letter scatter headline
Animations, beginner