Aurora

A curtain of light hanging from one edge of a section and reaching part of the way in, like an aurora: its free edge a slow broad wave, fine rays shimmering inside it, brightest just short of the free edge and fading toward the one it hangs from, its colour flowing across the width through three stops from the theme. Two curtains hang at different depths by default and move in parallax, and the whole drifts gently toward the pointer.

Installation

Import the class, and @use the entry point in your global styles. Nothing warns you when the @use is missing.

import { Component } from '@angular/core';
import { WrAurora } from 'ngwr/animations/aurora';

@Component({ imports: [WrAurora] })
export class MyComponent {}

Runs on the GPU

It draws on the GPU through WebGL, at half resolution at most under a pixel budget, only while on screen and the tab is visible, and at 30 frames a second. Without WebGL it draws nothing. Use one WebGL effect per view, and keep it off low-end and battery-sensitive pages if in doubt.

Basic

Put <wr-aurora /> first inside the region it should fill. The drawing is one WebGL pass: every pixel finds its place between the edge the curtain hangs from and the curtain's waving free edge, takes the brightness that place has (dim at the root, brightest just short of the free edge, soft past it), the shimmer of the rays, and the colour the three stops give at its place across the width. Nothing in the picture is sharp, so the canvas is drawn at half resolution at most and the browser's upscale softens it further for free. The context is made when the host is first on screen and sized, and the loop runs at thirty frames a second while it stays on screen and the document is visible. The parent takes the pointer, passively; a finger is ignored, so a scroll over the section is never fought.

<section class="hero">
  <wr-aurora />
  <h2>Built on the new Angular.</h2>
</section>

Built on the new Angular.

The curtain hangs from the top edge and drifts toward the pointer.

The parent

The host is absolute, inset: 0, at z-index: -1, under no pointer, and the curtain fades out softly at the sides. The parent provides two things: it is positioned, so the host fills it, and isolated, so the host's negative z-index lands at the floor of the parent's own stacking context, under the content and over the page background, and the parent's other children need no positioning of their own.

.hero {
  position: relative;
  isolation: isolate;
}

Edge and height

edge is the edge the curtain hangs from, the top unset or the bottom; height is how far into the region it reaches, as a share of the region's height, 0.45 unset. The brightest part sits just short of the free edge, so the text near the anchored edge reads over the dim root and the text near the free edge over the glow: a heading that sits where the glow lands wants the other edge, or a shorter curtain.

<wr-aurora edge="bottom" height="0.6" />

Default

From the top.

edge="bottom" height="0.6"

From the bottom, taller.

Colours

The colour flows across the width from --wr-aurora-color-1 at the inline start through -2 to -3 at the inline end: the success, the primary and a primary-danger violet by default, bare intents, since the curtain is a graphic and not text. The three are mixed in OKLCh, lightness and chroma moving linearly and the hue walking the shorter arc, so the colour between two stops is as saturated as either and never the grey an sRGB mix falls into; keep the three hues turning one way, as the defaults do, and no mix is far from its neighbours. Set the hooks on the host, where the defaults are declared; they are read through wrResolveCssColorChannels and re-read when the scheme changes. The surface is read too, and it decides the look. On a dark one the curtain is light added to the surface, saturated and brightest at its lower border, with the rays inside it. On a light one nothing can glow, so it is a pale wash instead: each stop's hue at one high lightness and a fraction of its chroma, one broad soft shape with no bright border, a slower edge and a long dissolve into the surface, the rays a whisper of texture. The same stops drive both.

<wr-aurora style="--wr-aurora-color-1: var(--wr-color-warning); --wr-aurora-color-2: var(--wr-color-danger); --wr-aurora-color-3: var(--wr-color-primary)" />

Warning, through danger, into the primary.

Calm vs lively

amplitude is how far the free edge's wave moves it, one being about a quarter of the curtain's height; scale is the size of the shapes, one putting about a wave and a half across the width; speed is how fast the wave, the rays and the hue move; layers is how many curtains hang at different depths, from one to three, the farther one broader, slower and dimmer. A single tall, slow wave is a calm sky; three short, quick ones are a storm of light.

<wr-aurora amplitude="1.5" scale="0.7" speed="1.8" layers="3" />

amplitude="0.5" scale="1.6" speed="0.5" layers="1"

Calm.

amplitude="1.5" scale="0.7" speed="1.8" layers="3"

Lively.

Rays

rays is how strongly the fine vertical rays show inside the curtain, from none to one, 0.6 unset: they are brightest near the free edge and fade toward the root, lean a little with the wave and shimmer on a clock of their own. None is a smooth curtain; one is all rays. glow scales the whole light, the wash's alpha on a light surface and the glow on a dark one. On a light surface the rays stay a whisper even at one: a hint of texture in the wash, never stripes.

<wr-aurora rays="0" />

rays="0"

Smooth.

rays="1"

All rays.

Intro and the pointer

intro fades the curtain in and lengthens it from a third of its height the first time the host is on screen, over about two and a half seconds; under reduced motion it is whole from the first frame. follow is the drift toward the pointer over the parent: the shapes move a little toward it across and the curtain reaches a little further where it is lower, the far layer less than the near one, and it eases back when the pointer leaves. Off, the curtain only waves.

<wr-aurora intro follow="false" />

Faded in on arrival.

API

NameDescriptionTypeDefault
edgeThe edge the curtain hangs from.WrAuroraEdge'top'
heightHow far into the region the curtain reaches, as a share of its height, from 0.1 to 1.number0.5
amplitudeHow far the free edge's wave moves it, a multiplier: one is about a quarter of the curtain's height; none is a straight edge.number1
scaleThe size of the shapes, a multiplier: one puts about a wave and a half across the width; more is broader.number1
speedHow fast the wave, the rays and the hue move, a multiplier: none holds the curtain still.number1
glowHow strong the light is, a multiplier on the wash's alpha and the glow.number1
raysHow strongly the rays show, from none to one.number0.6
layersHow many curtains hang at different depths, from one to three.number2
introWhether the curtain fades and lengthens in when first on screen.booleanfalse
followWhether the curtain drifts gently toward the pointer over the parent.booleantrue

Accessibility

PartBehaviour
Screen readers Decorative: the host is aria-hidden, holds no text, takes no pointer and is never focusable. The listeners on the parent are passive and stop nothing, so every control over the curtain behaves as before.
Touch A finger is ignored, nothing is prevented and touch-action is left alone, so a scroll that starts over the region scrolls.
Reduced motion Under prefers-reduced-motion: reduce one still frame of the whole curtain is drawn, at rest, with no drift and no intro, and nothing moves; a preference that flips mid-flight stops the loop at once. Under forced-colors: active nothing is drawn.
Contrast The root the curtain hangs from is dim, so text near the anchored edge reads over a faint tint. On a light surface the wash is pale throughout, so text keeps its contrast wherever it sits: measured under the first demo above, over several frames and at the worst pixel, the heading keeps 15:1 and the lead 5.7:1. On a dark surface the brightest part sits just short of the free edge: the heading never falls under 11:1 and the lead keeps 6.5:1 over most of its pixels, but where a bright ray crosses the lead's lowest line the worst pixel is about 2.2:1. Muted text that must sit under the glow in dark wants the other edge, a shorter height or a lower glow.
No WebGLWithout WebGL nothing is drawn; a lost context is let go and rebuilt when the browser restores it.
ServerThe empty canvas is rendered, absolutely positioned, so the browser's first draw shifts no layout.

See also