Skip to content
animorio
IT
Back to the library

Full moon background

Backgrounds, HoverGSAP, CSS onlyEasyCompressed weight: Demo 5.8 KBGSAP 28 KBFreeDownload the zip

A night background to put behind a headline: on near black blue a bone white full moon rises slowly from below, goes one pixel past its place and stops behind the words, and its light catches only the top edge of the letters. With the pointer the moon moves by a few pixels, late, and the thread of light on the letters follows it.

The code

A folder that runs on its own: index.html, style.css, script.js and the libraries from a CDN. The React and Vue tabs hold the same demo as a ready component, which switches its animations off when it leaves the page.

<!doctype html>
<!--
  "Full moon background" from Animorio · https://animorio.com
  License: free on your own sites and your clients’ sites, paid work included.
  Not for resale, redistribution, templates or code collections · https://animorio.com/en/license/
-->
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>The background of the full moon rising behind the headline</title>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/mona-sans@5.3.0/wdth.css">
  <link rel="stylesheet" href="style.css">
</head>
<body>
  <!-- a near black blue night with a big headline in the middle: behind it a full moon rises slowly from below and
       stops behind the words, and its light catches only the top edge of the letters; the moon follows the pointer by a
       few pixels, late, and the light on the letters follows the moon -->
  <main class="stage" data-stage>
    <span class="halo" data-halo aria-hidden="true"></span>
    <div class="moon" data-moon aria-hidden="true">
      <span class="moon__face" data-face>
        <i class="moon__mare moon__mare--a"></i>
        <i class="moon__mare moon__mare--b"></i>
        <i class="moon__mare moon__mare--c"></i>
      </span>
    </div>
    <span class="grain" aria-hidden="true"></span>

    <!-- the moonlight on the letters: each letter minus itself pushed a hair away from the moon leaves only the edge
         that faces the moon, filled in bone -->
    <svg class="defs" width="0" height="0" aria-hidden="true">
      <filter id="moonlit" x="-4%" y="-8%" width="108%" height="116%" color-interpolation-filters="sRGB">
        <feOffset in="SourceAlpha" dx="0" dy="4" result="away" data-away></feOffset>
        <feGaussianBlur in="away" stdDeviation="0.2 0.9" result="soft" data-soft></feGaussianBlur>
        <feComposite in="SourceAlpha" in2="soft" operator="out" result="edge"></feComposite>
        <feFlood flood-color="#fffaee" data-flood></feFlood>
        <feComposite in2="edge" operator="in"></feComposite>
      </filter>
    </svg>

    <section class="hero" aria-labelledby="hero-title">
      <div class="words" data-words>
        <h1 class="title title--body" id="hero-title" data-title>After<br>dark</h1>
        <p class="title title--rim" data-rim aria-hidden="true">After<br>dark</p>
      </div>
      <p class="lede" data-lede>Open after sundown</p>
    </section>
  </main>

  <script src="https://cdn.jsdelivr.net/npm/gsap@3.15.0/dist/gsap.min.js"></script>
  <script src="script.js"></script>
</body>
</html>

Playground

Change values, colours and text with the controls and watch the animation respond live. Or write in the code yourself. Then download the folder with your changes.

22 values to change

Or ask your AI assistant for it

With the Animorio connector, Claude Code, ChatGPT, Cursor or VS Code take it from here, guide included, and fit it into your project. Paste this request:

Take “Full moon background” from Animorio and fit it into my site
Platform licenseFree on your sites and your clients’ sites. Want it inside a website builder, a template platform or a client dashboard? There’s a license for agencies and platforms.

What it does

A near black night, just blue, a little lighter towards the bottom. In the middle a big headline on two lines, ‘After dark’, in dark letters but one shade lighter than the sky, so they read even in the dark; under it, small and blue grey, the line ‘Open after sundown’. From the bottom edge a bone white full moon rises: just a circle, lighter at the top left, with three round shadows barely there and a soft light around it. It rises quickly at first and then slows down for a long time, while the sky around it brightens; it arrives behind the headline, a little above its middle, goes one pixel past its place and settles. The letters in front of the moon become dark silhouettes and, as the moon comes closer, its light lights a bone white thread only on the top edge of each letter, inside the letter, as if the light grazed it from behind, strongest near the moon and fainter further away. With the pointer the moon moves a few pixels towards it, late, on a soft spring that sways once, and the thread of light slides slightly to that side; pressing makes the moon brighter for a moment and the thread thicker, then it comes back with a small elastic. If nobody moves the pointer an invisible one moves it, in a slow figure of eight. The light breathes slowly. After a few seconds the moon sets downwards, the thread goes out and it starts rising again; a double click starts it over.

How it works

The same words, filtered

The headline is written twice in the same grid cell: underneath in solid dark letters, with a gradient clipped to the text; on top a copy through an SVG filter. The filter takes the shape of the letters, subtracts a copy pushed RIM em away from the moon (feOffset, softened a little with feGaussianBlur) and fills what is left with bone white: just the edge that faces the moon.

A round mask that follows the moon

The thread of light has a radial mask-image with its centre and radius in CSS variables: every frame the centre is the moon’s, measured in the headline’s coordinates. So letters near the moon shine and far ones barely do, and the thread lights up as the moon rises.

Numbers, not styles

How low the moon is, the pixel too far, the light and the press are numbers in an object GSAP animates; one draw in the ticker writes them into the moon, the halo and the thread. The rise is a long power3.out: quick at first, then a slowing down that feels like a horizon.

Late, on purpose

The moon chases the pointer on a soft spring (stiffness 26, damping 8.2), by FOLLOW pixels at most: it arrives late and sways once. The filter offset leans sideways as far as the moon moves from the middle of the headline, so the light also catches the sides facing it, and it is rewritten only when it changes by a tenth of a pixel.

Sizes in vw and vh

Moon and headline are sized with min() of vw and vh, so they fit the phone box as they fit a big screen; on resize the headline, the moon and its resting place are measured again, even halfway through the rise.

Values to change

NameFileDefaultWhat it changes
TITLEscript.jsAfter|darkThe headline (the vertical bar breaks the line).
LINEscript.jsOpen after sundownThe small line under the headline (empty to remove it).
RISEscript.js4.6How many seconds the moon takes to rise.
HEIGHTscript.js0.2How far above the middle of the headline it stops, as a share of the moon.
RIMscript.js0.024How thick the thread of light on the edge of the letters is, in em.
FOLLOWscript.js16How many pixels at most the moon follows the pointer.
GLOWscript.js1How strong the light around the moon is.
RESTscript.js6How many seconds it stays up before setting and rising again.
LOOPscript.jstrueSet and rise again.
AUTO_PILOTscript.js3After how many seconds without a pointer the invisible one starts moving (0 never).

Try them in the Playground

When to use it

As the background of the first screen of an evening event, a venue that opens at night, a festival, a night programme or a sleep app: the headline stays the star and the moon backlights it.

On phones

The same moon with adapted sizes: moon and headline are measured on the height too and fit the box; the finger moves the moon like the pointer and holding it down makes the moon brighter.

With reduced motion

The moon is already in place behind the headline: the light and the words appear in a fade, the moon does not follow the pointer and does not set; pressing brightens it slightly.

Pitfalls

  • The lit copy goes on top of the dark letters and the light is carved inside the letters themselves: a bone white copy shifted behind them is lost on the moon’s disc, which is the same colour.
  • A copy with opacity or a transform becomes a layer of its own and paints above the others: both copies have explicit position and z-index, or the order flips.
  • The filter blur goes vertical only (stdDeviation 0.2 0.9): equal in both directions it lights the sides of the letters too.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

Compressed with gzip, the three demo files weigh 5.8 KB; the libraries: GSAP 28 KB.

Testing

Tested on 31 October 2026

  • Desktop: Done
  • Phone: Done
  • Reduced motion: Done
  • Safari on iPhone: To do

License

Use it in your own projects and in your clients’ projects. Do not resell it or redistribute it as is. GSAP stays under its own Standard license. Full license.

All animations