Aurora Veil Login

A sign in form on a night sky with the northern lights. The veils lean toward the pointer and flare up next to it, and a sideways move pulls them along.

Move the pointer over the sky. Type any email and password and press Log in: a bright wave runs across the veils.

Download

What you can change

Change a number, save, and reload the page to see the difference.

AURORAnight, high, green, teal, violet

The night, the high sky and the green, teal and violet of the veils, each as red, green, blue.

VEIL1

How bright the veils are.

AURORA_DRAG1

How strongly a sideways move pulls the veils along.

Add it to your site

The sign in page of a studio, a portfolio or a product, anywhere the first screen can afford a little motion.

  1. CSS

    Paste into your stylesheet, or inside a <style> tag in <head>.

    /* page shell, only needed while this file is the whole page */
  2. HTML

    Put it where the effect should appear on your page.

    <!-- login start -->
    <main class="av">
      <section class="av-sky">
        <canvas class="av-air" aria-hidden="true"></canvas>
        <div class="av-sky-mid">
          <div class="av-sky-form">
            <h1 class="av-title av-glim">Log in</h1>
            <form class="av-form" novalidate data-busy="Logging in" data-label="Logged in" data-done="Welcome back. Change this line or send people to their page.">
              <div class="av-group">
                <label class="av-cell" for="av-user"><span>Email</span><input class="av-field" id="av-user" name="email" type="email" autocomplete="username" placeholder="you@example.com" data-need="Enter your email."></label>
                <label class="av-cell" for="av-pass"><span>Password</span><input class="av-field" id="av-pass" name="password" type="password" autocomplete="current-password" placeholder="Your password" data-need="Enter your password."></label>
              </div>
              <button class="av-btn" type="submit">Log in</button>
              <p class="av-note" role="status"></p>
            </form>
          </div>
        </div>
      </section>
    </main>
    <!-- login end -->
  3. JavaScript

    Paste right before the closing </body> tag, inside <script></script>.

    /* Aurora Veil Login by @codinvisual · t.me/CodinVisual · free for your own site, don't resell this file */
    (() => {
    const root = document.querySelector('.av');
    if (!root) return;
    
    const AURORA = { night: [6, 10, 22], high: [12, 22, 48], green: [70, 236, 170], teal: [60, 200, 215], violet: [150, 110, 255] };
    const VEIL = 1, AURORA_DRAG = 1, AURORA_PIXELS = 1.2e6;
    
    const reduce = matchMedia('(prefers-reduced-motion: reduce)').matches;
    root.classList.add('av-js');
    const $ = (s, el = root) => el.querySelector(s);
    const $$ = (s, el = root) => [...el.querySelectorAll(s)];
    const clamp = (x, a = 0, b = 1) => Math.min(b, Math.max(a, x));
    const wait = ms => new Promise(r => setTimeout(r, ms));
    
    /* aurora: veils of light hang over the page, sway slowly, lean toward the pointer and flare up next to it */
    const skies = [];
    $$('.av-air').forEach(cv => {
      if (reduce) return;
      const host = cv.parentNode;
      const gl = cv.getContext('webgl2', { alpha: false, antialias: false, depth: false });
      if (!gl) return;
      const rgb = c => c.map(v => (v / 255).toFixed(3)).join(', ');
      const FRAG = `#version 300 es
    precision highp float;
    in vec2 uv;
    out vec4 o;
    uniform float now, ratio, wave, flare, drift;
    uniform vec3 hand;
    const vec3 NIGHT = vec3(${rgb(AURORA.night)}), HIGH = vec3(${rgb(AURORA.high)}), GREEN = vec3(${rgb(AURORA.green)}), TEAL = vec3(${rgb(AURORA.teal)}), VIOLET = vec3(${rgb(AURORA.violet)});
    float hash(float x) { return fract(sin(x * 127.1) * 43758.5453); }
    float noise(float x) { float i = floor(x), f = fract(x); return mix(hash(i), hash(i + 1.), f * f * (3. - 2. * f)); }
    float hash2(vec2 p) { return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453); }
    // one veil: a ribbon of light seen from below. Its hem wanders in wide slow folds and never runs straight across the sky,
    // rays rise from it, lean where the ribbon turns and reach higher in some places than in others
    vec3 veil(vec2 p, float k, float seed, float speed) {
    float x = p.x * ratio;
    // the veil leans toward the hand and is pulled along when the finger drags it
    float pull = hand.z * exp(-pow((x - hand.x * ratio) * 1.6, 2.)) * exp(-pow((p.y - hand.y) * 1.4, 2.));
    float away = hand.x * ratio - x;
    x += pull * .5 * away * exp(-away * away * 2.2) + drift * (.6 + .4 * k);      // a smooth lean, with no seam at the hand
    float t = now * speed, a = x * 1.9 * k + t + seed;
    float hem = .3 + .1 * k + sin(a) * .11 + sin(x * 3.7 * k - t * .7 + seed * 2.3) * .05 + (noise(x * 1.3 + seed + t * .15) - .5) * .14;
    float above = p.y - hem;
    float turn = cos(a) * .21 * k;                                   // slope of the hem: where the ribbon turns toward us
    float rx = x + above * turn * 1.4;
    float r1 = noise(rx * 21. * k + seed * 9. + t * .5), r2 = noise(rx * 47. + seed * 3. - t * .3);
    float rays = .42 + .58 * r1 * (.55 + .9 * r2);
    float tall = .15 + .34 * noise(x * 2.1 * k + seed * 5. + t * .1);
    float body = smoothstep(-.07, .025, above) * exp(-max(above, 0.) / tall) * rays;
    float seam = exp(-pow(above / .045, 2.)) * .3 * (.5 + .5 * r1);     // a soft bright seam along the hem, no hard line
    float dense = 1. + abs(turn) * 4.5;                               // a fold seen edge-on is brighter
    vec3 c = mix(GREEN, TEAL, smoothstep(0., .24, above)) * (body + seam) * dense;
    c += VIOLET * smoothstep(.1, .4, above) * body * 1.1;
    float run = exp(-pow((p.x - wave) * 7., 2.)) * step(0., wave);
    return c * (1. + flare * .6 + pull * 1.4 + run * 2.2);
    }
    void main() {
    vec3 c = mix(NIGHT, HIGH, smoothstep(.2, 1., uv.y));
    vec2 g = uv * vec2(ratio, 1.) * 90.;
    float s = hash2(floor(g));
    if (s > .985) c += vec3(.55, .6, .75) * smoothstep(.3, 0., length(fract(g) - .5)) * (.35 + .25 * sin(now * (.5 + s * 3.) + s * 40.)) * smoothstep(.15, .6, uv.y);
    // the near ribbon low and bright, two farther ones higher, fainter and slower, so they read as depth and not as stripes
    c += veil(uv, 1., 0., .21) * ${(VEIL * .6).toFixed(2)};
    c += veil(uv * vec2(.8, 1.) + vec2(.31, -.1), .7, 4.1, .15) * ${(VEIL * .3).toFixed(2)};
    c += veil(uv * vec2(.62, 1.) + vec2(-.4, -.19), .5, 9.3, .1) * ${(VEIL * .17).toFixed(2)};
    o = vec4(1. - exp(-c * 1.6), 1.);
    }`;
      const VERT = '#version 300 es\nin vec2 a;\nout vec2 uv;\nvoid main() { uv = a * .5 + .5; gl_Position = vec4(a, 0., 1.); }';
      const sh = (type, src) => { const s = gl.createShader(type); gl.shaderSource(s, src); gl.compileShader(s); return s; };
      const prog = gl.createProgram();
      gl.attachShader(prog, sh(gl.VERTEX_SHADER, VERT)); gl.attachShader(prog, sh(gl.FRAGMENT_SHADER, FRAG));
      gl.bindAttribLocation(prog, 0, 'a'); gl.linkProgram(prog);
      if (!gl.getProgramParameter(prog, gl.LINK_STATUS)) return;
      gl.useProgram(prog);
      const U = {};
      for (const n of ['now', 'ratio', 'wave', 'flare', 'drift', 'hand']) U[n] = gl.getUniformLocation(prog, n);
      gl.bindBuffer(gl.ARRAY_BUFFER, gl.createBuffer());
      gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([-1, -1, 1, -1, -1, 1, 1, 1]), gl.STATIC_DRAW);
      gl.enableVertexAttribArray(0); gl.vertexAttribPointer(0, 2, gl.FLOAT, false, 0, 0);
      let W = 1, H = 1;
      function build() {
        W = host.clientWidth; H = host.clientHeight;
        if (!W || !H) return false;
        const k = Math.min(devicePixelRatio || 1, 2, Math.sqrt(AURORA_PIXELS / (W * H)));
        cv.width = Math.round(W * k); cv.height = Math.round(H * k);
        return true;
      }
      if (!build()) return;
      root.classList.add('av-lit');
      // the hand: where the pointer is (eased, so the veil follows like cloth in the wind) and how strongly it pulls
      let hx = .5, hy = .5, gx = .5, gy = .5, pull = 0, want = 0, drift = 0, push = 0, flare = 0, wave = -1;
      let shown = true, running = false, last = 0;
      function frame(now) {
        if (!shown || document.hidden) { running = false; return; }
        const t = now / 1000, dt = Math.min(t - last, 1 / 20); last = t;
        const e = 1 - Math.exp(-dt * 3.2);
        hx += (gx - hx) * e; hy += (gy - hy) * e; pull += (want - pull) * (1 - Math.exp(-dt * 2.4));
        drift += push * dt; push *= Math.exp(-dt * 1.8);
        flare = Math.max(0, flare - dt * .9);
        if (wave >= 0) wave = wave > 1.3 ? -1 : wave + dt / 1.1;
        gl.viewport(0, 0, cv.width, cv.height);
        gl.uniform1f(U.now, t); gl.uniform1f(U.ratio, W / H); gl.uniform1f(U.wave, wave); gl.uniform1f(U.flare, flare); gl.uniform1f(U.drift, drift);
        gl.uniform3f(U.hand, hx, hy, pull);
        gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
        requestAnimationFrame(frame);
      }
      const wake = () => { if (running || !shown || document.hidden) return; running = true; requestAnimationFrame(t => { last = t / 1000; frame(t); }); };
      const spot = e => { const r = cv.getBoundingClientRect(); return [(e.clientX - r.left) / r.width, 1 - (e.clientY - r.top) / r.height]; };
      let px = -1, pt = 0;
      host.addEventListener('pointermove', e => {
        const [x, y] = spot(e), now = performance.now() / 1000;
        if (px >= 0) push += (x - px) * AURORA_DRAG / Math.max(now - pt, 1 / 120) * .02;
        [gx, gy] = [x, y]; want = 1; px = x; pt = now;
      });
      host.addEventListener('pointerleave', () => { want = 0; px = -1; });
      host.addEventListener('pointercancel', () => { want = .4; px = -1; });
      // a touch lights a bright fold right where it lands
      host.addEventListener('pointerdown', e => {
        if (e.target.closest('a, button, input, textarea, label')) return;
        [gx, gy] = spot(e); hx = gx; hy = gy; pull = want = 1.6; flare = Math.max(flare, .5);
      });
      host.addEventListener('pointerup', e => { if (e.pointerType !== 'mouse') want = .4; });
      // scrolling the page slides the veils across the sky
      let top = scrollY;
      addEventListener('scroll', () => { const d = scrollY - top; top = scrollY; if (shown) push += d * .004; }, { passive: true });
      skies.push({ host, run() { wave = 0; flare = 1; } });
      new ResizeObserver(() => { if (cv.width && Math.abs(host.clientWidth - W) + Math.abs(host.clientHeight - H) > 2) build(); }).observe(host);
      new IntersectionObserver(([e]) => { shown = e.isIntersecting; wake(); }).observe(cv);
      document.addEventListener('visibilitychange', wake);
      wake();
    });
    
    /* headlines: the letters light up from the top down, as if a veil passed over them */
    $$('.av-glim').forEach(el => {
      if (reduce) return;
      el.innerHTML = el.textContent.trim().split(' ').map(w => `<span class="av-wd">${[...w].map(c => `<span class="av-ch">${c}</span>`).join('')}</span>`).join(' ');
      const chars = $$('.av-ch', el), box = el.getBoundingClientRect();
      chars.forEach((c, i) => {
        const r = c.getBoundingClientRect(), down = (r.top - box.top) / Math.max(box.height, 1), across = (r.left - box.left) / Math.max(box.width, 1);
        setTimeout(() => c.classList.add('av-on'), 250 + down * 700 + across * 260 + (i % 3) * 40);
      });
    });
    
    /* the form: checks the fields, waits for the server, then a bright wave runs across the sky */
    $$('.av-form').forEach(form => {
      const btn = $('.av-btn', form), note = $('.av-note', form), fields = $$('.av-field', form);
      form.addEventListener('submit', async e => {
        e.preventDefault();
        const bad = fields.find(f => !f.value.trim() || f.type === 'email' && !/^\S+@\S+\.\S+$/.test(f.value.trim()));
        fields.forEach(f => f.closest('.av-cell').classList.toggle('av-bad-cell', f === bad));
        form.classList.toggle('av-form-bad', !!bad);
        if (bad) {
          note.textContent = bad.type === 'email' && bad.value.trim() ? 'That does not look like an email. Try one like name@example.com.' : bad.dataset.need || 'Fill in this field first.';
          bad.focus();
          return;
        }
        btn.disabled = true; btn.textContent = form.dataset.busy || 'Sending';
        // a real server request goes here, for example:
        // await fetch('/api/login', { method: 'POST', body: new FormData(form) });
        await wait(700);
        fields.forEach(f => { f.disabled = true; });
        btn.textContent = form.dataset.label || 'Sent';
        form.classList.add('av-sent');
        note.textContent = form.dataset.done || 'Thank you. We will write back soon.';
        skies.forEach(s => s.run());
      });
      fields.forEach(f => f.addEventListener('input', () => { form.classList.remove('av-form-bad'); f.closest('.av-cell').classList.remove('av-bad-cell'); note.textContent = ''; }));
    });
    })();

Connect it to your backend

The form sends nothing until you connect it. Search for a real server request goes here, put your fetch() there and remove the timer on the next line.

Good to know

Tilda, Webflow, WordPress

Press Copy all code at the top and paste it into one HTML block.

Tilda

Add block, Other, T123 HTML code. Paste and save. Check the published page, the editor preview does not run scripts.

Webflow

Add panel, Embed. Paste, then Save & Close. Custom code runs on the published site.

WordPress

Add block, Custom HTML. Paste and press Update.

More in Sign in & forms

See all
Copied