All effectsPlay & loop

Aurora Background

极光背景

Soft green, violet, and blue ribbons bend and overlap against a dark backdrop.

Play the demo to watch the light bands drift

Where to use it

Set the mood behind a hero headline or a sign-in form. Keep the brightest portion of the bands away from form fields and reserve a dark patch for the heading.

Practical example

An astronomy app uses layered aurora ribbons around the edges of its sign-in screen. The form sits on a stable dark area at the center.

Also called

  • Northern Lights
  • Aurora Shader

AI prompt

Add an Aurora Background behind [hero]. Use blurred, flowing color bands in green, violet, and blue that slowly warp. Preserve text contrast. Pause motion when reduced motion is requested.

Example code

Save the standalone HTML as a file and open it in your browser. It uses the same code as the preview.

View HTML
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Aurora Background</title>
  <style>
    :root {
      color-scheme: dark;
      --demo-bg: #171629;
      --demo-ink: #f8f5ff;
      --demo-accent: #b9a6ff;
      --demo-muted: #bfbbd3;
      font-family: system-ui, sans-serif;
      color: var(--demo-ink);
      background: var(--demo-bg);
    }

    *, *::before, *::after { box-sizing: border-box; }
    body { margin: 0; min-width: 0; }
    button, input { font: inherit; }

    .demo {
      display: grid;
      place-items: center;
      align-content: center;
      min-height: 100vh;
      padding: 14px;
      overflow: hidden;
      background: radial-gradient(ellipse at 50% 24%, #28233f, var(--demo-bg) 78%);
    }

    .demo-button {
      border: 1px solid #ffffff3d;
      border-radius: 7px;
      background: #ffffff12;
      color: var(--demo-ink);
      padding: 6px 11px;
      font-size: 12px;
      cursor: pointer;
    }

    :focus-visible {
      outline: 2px solid var(--demo-accent);
      outline-offset: 3px;
    }

    .demo { position: relative; padding: 0; }
    .showcase { position: absolute; inset: 0; isolation: isolate; overflow: hidden; }
    .showcase .demo-button {
      position: absolute;
      z-index: 3;
      bottom: 10px;
      left: 50%;
      transform: translateX(-50%);
      border-radius: 999px;
      background: #101026d9;
      color: #f1efff;
      white-space: nowrap;
    }
    .showcase :is(h1, p) { margin: 0; }
    .scene-copy {
      position: absolute;
      z-index: 1;
      inset: 0;
      display: grid;
      place-content: center;
      padding: 14px;
      text-align: center;
      pointer-events: none;
    }
    .scene-copy h1 {
      font-size: clamp(25px, 8vw, 62px);
      line-height: 1;
      letter-spacing: -.045em;
    }
    .showcase [data-motion] { animation-play-state: paused; }
    .showcase[data-playing] [data-motion] { animation-play-state: running; }
    @media (prefers-reduced-motion: reduce) {
      .showcase [data-motion] { animation: none; }
      .showcase [data-loop-toggle] { display: none; }
    }

    .showcase {
      background: radial-gradient(ellipse at 50% 76%, #253f60, #11172d 52%, #091221 88%);
    }
    .aurora-curtains { position: absolute; inset: 0; overflow: hidden; }
    .curtain {
      position: absolute;
      inset: 3% -23% auto;
      height: 80%;
      border-radius: 44% 61% 37% 61% / 42% 39% 64% 62%;
      transform: rotate(-15deg) skewX(-14deg);
      filter: blur(clamp(4px, 1.8vw, 12px));
      mix-blend-mode: screen;
      animation: curtain-drift 12s ease-in-out infinite alternate;
    }
    .curtain-blue {
      background: linear-gradient(169deg, transparent 12%, #2777f96b 33%, #4f9bffcf 49%, transparent 61%);
    }
    .curtain-violet {
      top: -10%; left: -22%; right: -8%;
      background: linear-gradient(172deg, transparent 24%, #9650c781 47%, #d080d7ba 65%, transparent 70%);
      transform: rotate(12deg) skewX(18deg);
      animation-delay: -6s;
    }
    .curtain-green {
      top: 10%; left: -10%; right: -17%;
      background: linear-gradient(170deg, transparent 22%, #42bc8f6b 33%, #54eec6bf 48%, #63f7b4db 54%, transparent 65%);
      transform: rotate(-11deg) skewX(-22deg);
      animation-delay: -3s;
    }
    .aurora-ridge {
      position: absolute;
      inset: auto 0 0;
      height: 27%;
      background: linear-gradient(#151d35, #0b1122 65%);
      clip-path: polygon(0 57%, 12% 44%, 20% 61%, 33% 29%, 38% 40%, 47% 16%, 63% 60%, 73% 36%, 78% 48%, 87% 13%, 100% 52%, 100% 100%, 0 100%);
    }
    .scene-copy h1 {
      font-family: Georgia, serif;
      font-weight: 400;
      color: #f3fff8;
      text-shadow: 0 2px 13px #061c2d, 0 0 28px #072555;
    }
    @keyframes curtain-drift {
      to {
        transform: translate(9%, 6%) rotate(9deg) skewX(13deg) scale(1.15, .9);
        border-radius: 62% 37% 64% 39% / 40% 64% 35% 61%;
      }
    }
  </style>
</head>
<body>
  <main class="demo">
    <div class="showcase">
      <div class="aurora-curtains" aria-hidden="true">
      <i class="curtain curtain-blue" data-motion></i>
      <i class="curtain curtain-violet" data-motion></i>
      <i class="curtain curtain-green" data-motion></i>
    </div>
    <div class="scene-copy"><h1>Northern Lights</h1></div>
    <div class="aurora-ridge" aria-hidden="true"></div>
      <button class="demo-button" type="button" data-loop-toggle data-testid="effect-demo-loop-toggle">Play demo</button>
    </div>
  </main>
  <script>
    const showcase = document.querySelector('.showcase');
    const toggle = showcase.querySelector('[data-loop-toggle]');
    const preference = matchMedia('(prefers-reduced-motion: reduce)');
    let playing = false;



    function syncPlayback() {
      if (preference.matches) playing = false;
      const active = playing && !document.hidden;
      showcase.toggleAttribute('data-playing', active);
      toggle.textContent = playing ? "Pause demo" : "Play demo";
      
    }

    toggle.addEventListener('click', () => {
      playing = !playing;
      syncPlayback();
    });
    preference.addEventListener('change', syncPlayback);
    document.addEventListener('visibilitychange', syncPlayback);
  </script>
</body>
</html>

Original example by UI Skills