An unseen moon slides across the sun, trimming it to a crescent, then totality lights up a glowing corona before the sun returns. The moon is a moving mask, so any background shows through.
Also known as: eclipse animation, total eclipse loader, moon covering sun.
<div class="ldr-eclipse" role="status" aria-label="Loading"> <span class="ldr-eclipse-corona"></span> <span class="ldr-eclipse-sun"></span> </div>
.ldr-eclipse {
--s: var(--ldr-size, 48px);
--c: var(--ldr-color, #3b82f6);
--moon: radial-gradient(circle, transparent calc(var(--s) * 0.52), #000 calc(var(--s) * 0.52 + 0.5px)) 0 0 / 320% 100% no-repeat;
position: relative;
width: var(--s);
height: var(--s);
}
.ldr-eclipse-corona {
position: absolute;
inset: 0;
border-radius: 50%;
box-shadow: 0 0 0 calc(var(--s) / 40) var(--c), 0 0 calc(var(--s) / 4) calc(var(--s) / 16) color-mix(in srgb, var(--ldr-color, #3b82f6) 55%, transparent);
opacity: 0;
animation: ldr-eclipse-corona 3s infinite;
}
.ldr-eclipse-sun {
position: absolute;
inset: 0;
border-radius: 50%;
background: var(--c);
-webkit-mask: var(--moon);
mask: var(--moon);
animation: ldr-eclipse-transit 3s infinite;
}
@keyframes ldr-eclipse-transit {
0% { -webkit-mask-position: 0% 0; mask-position: 0% 0; animation-timing-function: cubic-bezier(0.3, 0, 0.45, 1); }
42%, 58% { -webkit-mask-position: 50% 0; mask-position: 50% 0; animation-timing-function: cubic-bezier(0.55, 0, 0.7, 1); }
100% { -webkit-mask-position: 100% 0; mask-position: 100% 0; }
}
@keyframes ldr-eclipse-corona {
0%, 34%, 66%, 100% { opacity: 0; }
42%, 58% { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
.ldr-eclipse, .ldr-eclipse *, .ldr-eclipse::before, .ldr-eclipse::after, .ldr-eclipse *::before, .ldr-eclipse *::after {
animation-duration: 3s;
}
}--ldr-color on the element or a parent.
Currently previewing #3b82f6.--ldr-size. Every dimension in the snippet is
derived from it. Currently previewing 64px.animation shorthand.
Delays on the children are relative, so they keep their rhythm.role="status" and an
aria-label so screen readers announce the wait. The reduced-motion rule
at the end slows the animation for users who asked for less motion.