Skip to content
animorio
IT
All components

Moon phase card

Weather, Hover, TransitionsGSAP, CSS onlyMediumCompressed weight: Demo 7.1 KBGSAP 28 KBFreeDownload the zip

The moon card of Nimbo, a made-up weather app, in dark glass on black: the moon disc with its seas in soft greys and a true terminator shadow, a semicircle plus an elliptical arc, sliding to the day’s phase on a spring. Below, the phase name, the illuminated percentage counting up, moonrise and moonset, and a strip of the next seven days with tiny discs to drag through. The halo widens towards the full moon.

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>
<!--
  "Moon phase card" 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>Moon phase card</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>
  <main class="stage">
    <!-- the moon card of a made-up weather app, Nimbo: the disc with the real terminator, the light that rolls,
         the phase name, moonrise and moonset, and the next seven days to drag through -->
    <section class="card" data-card aria-label="Moon phase">
      <span class="card__rim" aria-hidden="true"></span>
      <header class="head">
        <p class="head__app">
          <svg class="head__mark" viewBox="0 0 16 16" aria-hidden="true"><path d="M10.6 2.4a5.8 5.8 0 1 0 3 9.8 4.6 4.6 0 0 1-3-9.8Z"/></svg>
          <span>Moon</span><span class="head__place">Lisbon</span>
        </p>
        <p class="head__date"><span class="roll" data-roll="date"><span class="roll__line">Wed, Nov 25</span></span></p>
      </header>

      <div class="sky" data-sky>
        <span class="halo" data-halo aria-hidden="true"></span>
        <svg class="moon" data-moon viewBox="0 0 200 200" role="img" aria-label="The moon tonight">
          <defs>
            <radialGradient id="mBase" cx="44%" cy="40%" r="62%">
              <stop offset="0" stop-color="#eef1f5"/>
              <stop offset=".62" stop-color="#c9ced6"/>
              <stop offset="1" stop-color="#8f96a1"/>
            </radialGradient>
            <radialGradient id="mLimb" cx="50%" cy="50%" r="50%">
              <stop offset=".72" stop-color="#000" stop-opacity="0"/>
              <stop offset="1" stop-color="#1a2230" stop-opacity=".38"/>
            </radialGradient>
            <filter id="mSoft" x="-10%" y="-10%" width="120%" height="120%"><feGaussianBlur stdDeviation="2.6"/></filter>
            <filter id="mEdge" x="-10%" y="-10%" width="120%" height="120%"><feGaussianBlur stdDeviation="1.1"/></filter>
            <clipPath id="mDisc"><circle cx="100" cy="100" r="88"/></clipPath>
            <mask id="mLit" maskUnits="userSpaceOnUse" x="0" y="0" width="200" height="200">
              <path data-lit fill="#fff" filter="url(#mEdge)" d=""/>
            </mask>
            <g id="mFace">
              <circle cx="100" cy="100" r="88" fill="url(#mBase)"/>
              <g filter="url(#mSoft)" fill="#7d8590">
                <ellipse cx="74" cy="70" rx="24" ry="18" opacity=".42"/>
                <ellipse cx="108" cy="62" rx="16" ry="13" opacity=".36"/>
                <ellipse cx="124" cy="88" rx="20" ry="15" opacity=".34"/>
                <ellipse cx="86" cy="104" rx="19" ry="12" opacity=".3"/>
                <ellipse cx="60" cy="118" rx="13" ry="20" opacity=".28"/>
                <ellipse cx="140" cy="118" rx="10" ry="8" opacity=".26"/>
              </g>
              <g fill="none" stroke="#f6f8fb" stroke-width="1" opacity=".5">
                <circle cx="112" cy="150" r="5"/>
                <circle cx="138" cy="60" r="3"/>
                <circle cx="70" cy="146" r="3.4"/>
              </g>
              <g fill="#6f7782" opacity=".35">
                <circle cx="113" cy="151" r="3.4"/>
                <circle cx="138.6" cy="60.6" r="2"/>
                <circle cx="70.5" cy="146.6" r="2.3"/>
              </g>
              <circle cx="100" cy="100" r="88" fill="url(#mLimb)"/>
            </g>
          </defs>
          <g clip-path="url(#mDisc)">
            <g data-face-wrap>
              <use href="#mFace" class="moon__shade"/>
              <use href="#mFace" mask="url(#mLit)"/>
            </g>
          </g>
          <circle class="moon__ring" cx="100" cy="100" r="88"/>
        </svg>
      </div>

      <div class="read">
        <p class="read__name"><span class="roll" data-roll="name"><span class="roll__line">Waxing Gibbous</span></span></p>
        <p class="read__light"><span class="read__pct" data-pct>0</span><span class="read__unit">%</span> <span class="read__lab">illuminated</span></p>
      </div>

      <dl class="times">
        <div class="times__item">
          <dt><svg viewBox="0 0 16 16" aria-hidden="true"><path d="M2 12.5h12M8 10V3.6M5.4 6.2 8 3.6l2.6 2.6"/></svg>Moonrise</dt>
          <dd><span class="roll" data-roll="rise"><span class="roll__line">14:02</span></span></dd>
        </div>
        <div class="times__item">
          <dt><svg viewBox="0 0 16 16" aria-hidden="true"><path d="M2 12.5h12M8 3.6V10M5.4 7.4 8 10l2.6-2.6"/></svg>Moonset</dt>
          <dd><span class="roll" data-roll="set"><span class="roll__line">03:11</span></span></dd>
        </div>
      </dl>

      <div class="week" data-week role="slider" tabindex="0" aria-label="Day" aria-valuemin="0" aria-valuemax="6" aria-valuenow="0">
        <span class="week__pick" data-pick aria-hidden="true"></span>
      </div>
    </section>
    <p class="sr" aria-live="polite" data-live></p>
  </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.

24 values to change

Works with Claude, Claude Code, ChatGPT, Cursor, VS Code, Windsurf, Codex, Gemini CLI

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 “Moon phase card” 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

On black, Nimbo’s dark glass card: «Moon» and Lisbon on the left at the top and the date on the right. In the middle the moon disc, light with soft grey seas and a few craters, its shadowed part barely visible like earthshine, with a pale blue halo behind. Below, the phase name, «Waxing Gibbous», the illuminated percentage in blue, Moonrise and Moonset, and the strip of seven days, each with its tiny disc and a pill marking the chosen one. Drag along the strip, or use the arrow keys, and the pill slides on a spring, the shadow sweeps across the disc to that day’s phase, the date, name and times roll, the percentage counts and the halo grows or shrinks. The disc follows the pointer a little. If nobody touches it, the card walks through the days by itself.

How it works

The real phase

Each day’s phase comes from the new moon of 6 January 2000 and the 29.53-day synodic month: 0 is new moon, 0.5 full moon. The lit fraction is (1 − cos 2πp) / 2.

The terminator

The lit part is a path: the limb semicircle on the light side plus an elliptical arc |cos 2πp| times the radius wide, bending one way or the other for a crescent or a gibbous moon. The path is a slightly blurred mask, so the shadow edge is soft.

The moon’s face

A circle with a radial gradient, six blurred grey ellipses for the seas, three craters with a light rim and a dark veil at the limb. The same face sits underneath at 7.5%, like earthshine.

The phase spring

On a new day GSAP takes the phase to the new value with back.out and redraws the path every frame; the face turns two degrees and comes back on an elastic spring, the percentage counts, the halo changes scale and opacity.

The day strip

Seven buttons with their tiny discs drawn by the same function; the pill slides onto the chosen day with back.out and squashes slightly while dragging. Date, name and times change with two rolling lines.

Values to change

NameFileDefaultWhat it changes
STARTscript.js"2026-11-25"The first day of the strip (yyyy-mm-dd).
DAYSscript.js7How many days the strip shows.
SPRINGscript.js0.9Seconds the disc takes to reach the new phase.
OVERSHOOTscript.js1.3How much the phase overshoots and settles (0 = none).
HALOscript.js1How strong the halo grows towards the full moon (0 = no halo).
AUTO_STEPscript.js1.5Seconds between days when nobody touches the card.
IDLEscript.js3Seconds of no touch before the card scrolls the days by itself.

Try them in the Playground

When to use it

On the weather page of an app or a site: for the evening, for people who photograph, fish, sail or hike, for a garden’s lunar calendar, for a wellbeing or horoscope app, for a hotel or a campsite offering nights under the moon.

On phones

Everything is in em and the size depends on both the width and the height of the window, so the whole card fits the phone box. On the strip you drag with a finger; the moon doesn’t follow the pointer where there is no hover.

With reduced motion

No springs or rolling: the disc changes phase at once with a short fade, the lines change with a fade, the pill jumps to the chosen day.

Pitfalls

  • The terminator isn’t a circle covering the moon: it’s an elliptical arc with horizontal radius |cos 2πp|·R. The arc’s sweep flips between crescent and gibbous and between waxing and waning.
  • The light path goes into a mask, not a clipPath: a clipPath can’t be blurred, a mask can, and the shadow edge stays soft.
  • The moon face turns with svgOrigin «100 100» because it’s a group inside the svg; on the whole svg you’d need transformOrigin 50% 50%.
  • Moonrise and moonset are an estimate from the phase (about 50 minutes later each day), not an astronomical calculation for the city: for a real site take them from a weather service.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

Tested on 25 November 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 components