Backgrounds

Aurora

An animated aurora-gradient background container — theme-token blobs drifting in pure CSS.

Preview in your theme

Loading preview…

import * as React from "react"
import { cn } from "@/lib/utils"

/**
 * Keyframes ship inside the component via React 19 hoisted <style> —
 * no tailwind config edits, and duplicates dedupe by href.
 */
const KEYFRAMES = `@keyframes zy-aurora-a{0%,100%{transform:translate3d(0,0,0) scale(1)}33%{transform:translate3d(18%,12%,0) scale(1.15)}66%{transform:translate3d(-10%,22%,0) scale(0.9)}}
@keyframes zy-aurora-b{0%,100%{transform:translate3d(0,0,0) scale(1.05)}33%{transform:translate3d(-16%,14%,0) scale(0.92)}66%{transform:translate3d(12%,-10%,0) scale(1.18)}}
@keyframes zy-aurora-c{0%,100%{transform:translate3d(0,0,0) scale(0.95)}40%{transform:translate3d(14%,-18%,0) scale(1.12)}70%{transform:translate3d(-18%,-6%,0) scale(1)}}`

/** color-mix alpha tier per intensity — the single knob for how loud the glow is. */
const ALPHA = {
  subtle: "20%",

Installation

npx shadcn@latest add https://ui.zyeon.ai/r/aurora.json

Prompt

The prompt behind this component — paste it into your AI assistant to recreate or adapt it.

Build a React + TypeScript + Tailwind "Aurora" component — an animated
aurora-gradient background container. Its only dependency is a cn() class
merger (clsx + tailwind-merge). No hooks, no events, no browser APIs, so it
must stay a server component — do NOT add "use client".

Contract
- export function Aurora(props): props extend React.ComponentProps<"div">
  (rest props + ref spread onto the root div) plus:
  - intensity?: "subtle" | "medium" | "bold" (default "medium") — selects a
    color-mix alpha tier for the blobs: 20% / 32% / 45%.
  - speed?: number (default 18) — seconds for one drift cycle of the base
    blob; the other blobs derive their durations from it.
- children render above the effect layer; className merges onto the root, so
  sizing, borders and rounding come from the call site.

Behavior
- Root div: relative isolate overflow-hidden. It publishes two CSS custom
  properties via inline style: --zy-aurora-speed = `${speed}s` and
  --zy-aurora-alpha = the tier percentage. Consumer style is spread after
  them, so both are overridable per instance without touching source.
- One absolutely-positioned layer (aria-hidden, pointer-events-none, inset-0)
  holds three oversized blob divs (rounded-full + blur-3xl), each hanging off
  a different edge (top-left, top-right, bottom) so the center of the
  container stays calm for content.
- Each blob runs its own @keyframes loop cycling transform between three
  poses (translate3d in own-size percentages + scale 0.9–1.18). Durations
  derive from the speed var — 1x, calc(*1.4), calc(*0.8) — and the offset
  blobs get negative animation-delay (calc of the same var) so their phases
  never sync into a visible repeat.
- The @keyframes ship inside the component via a React 19 hoisted
  <style href="zyeon-aurora" precedence="medium"> tag — no Tailwind config
  edits, and multiple instances dedupe to one style tag by href.
- prefers-reduced-motion: every blob gets motion-reduce animation:none but
  remains rendered — the decoration stays visible, it just stops drifting.
  No functional loss.
- Children are wrapped in a relative z-10 div above the effect layer, so the
  glow can never intercept clicks or sit over text.

Rendering & styling
- Semantic tokens only. Each blob's fill is
  radial-gradient(closest-side, color-mix(in oklab, <token>
  var(--zy-aurora-alpha), transparent), transparent) with one token per blob:
  var(--primary), var(--chart-2), var(--chart-4). No hex / rgb() / oklch()
  anywhere — the aurora re-skins itself with the host theme and dark mode.
- The alpha ceiling (45% at "bold") plus blur-3xl keeps overlaid foreground
  text readable in both color schemes.
- Merge consumer className via cn() on the root div.

Customization levers
- Palette: swap var(--chart-2) / var(--chart-4) for any other theme tokens
  (--chart-1..5, --secondary, --accent) — one token string per blob.
- Intensity tiers: the ALPHA map is the single source of loudness; re-tune
  20/32/45 or add tiers (e.g. faint: "12%") without touching anything else.
- Speed: per instance via the prop, or override --zy-aurora-speed in style
  for one-off pacing; larger numbers are slower and calmer.
- Blob count: a fourth blob is one more div + one more @keyframes block;
  positions and sizes are percentage-based so they scale with the container.
- Scoped usage: it is just a div — wrap a card header, sidebar section or
  banner, not only page heroes; className rounding + overflow-hidden clip
  the glow to any shape.

Concepts

  • Token-derived glow — blob colors are color-mix() over --primary and --chart-*, so the aurora adopts the host theme and dark mode with zero configuration; changing the palette is swapping token names, not repainting gradients.
  • CSS-var contractspeed and the intensity alpha travel as custom properties from props into arbitrary-value classes; any instance can be re-paced or re-tinted through style without forking the component.
  • Phase-staggered drift — three loops share one base duration but run at 1x / 1.4x / 0.8x with negative delays, so the composition never visibly repeats even though each loop is short.
  • Reduced-motion honesty — under prefers-reduced-motion the blobs freeze rather than disappear: the ambience (and any contrast it provides) is preserved while all movement stops.
  • Layer separation — decoration lives in a single aria-hidden, pointer-events-none layer; content sits in a z-10 layer above it, so the glow can never capture clicks or enter the accessibility tree.
  • Server-component purity — no hooks, no events, no "use client": the aurora renders on the server and animates entirely in CSS.

On This Page