The sun peeks out from behind a drifting cloud with slowly turning rays, the 'partly cloudy' icon brought to life. Rays are a masked repeating-conic-gradient, so the ring stays crisp.
Also known as: weather loading animation, partly cloudy animation css, sun behind cloud loader.
<div class="ldr-sun-cloud" role="status" aria-label="Loading"> <span class="ldr-sun-cloud-sun"></span> <span class="ldr-sun-cloud-cloud"></span> </div>
.ldr-sun-cloud {
--s: var(--ldr-size, 48px);
--c: var(--ldr-color, #3b82f6);
position: relative;
width: calc(var(--s) * 1.25);
height: var(--s);
}
.ldr-sun-cloud-sun {
position: absolute;
left: 22%;
top: 14%;
width: calc(var(--s) * 0.42);
height: calc(var(--s) * 0.42);
border-radius: 50%;
background: color-mix(in srgb, var(--ldr-color, #3b82f6) 60%, transparent);
animation: ldr-sun-cloud-peek 3.2s ease-in-out infinite;
}
.ldr-sun-cloud-sun::before {
content: "";
position: absolute;
inset: calc(var(--s) * -0.16);
border-radius: 50%;
background: repeating-conic-gradient(color-mix(in srgb, var(--ldr-color, #3b82f6) 60%, transparent) 0 14deg, transparent 0 45deg);
-webkit-mask: radial-gradient(closest-side, transparent 66%, #000 69% 97%, transparent);
mask: radial-gradient(closest-side, transparent 66%, #000 69% 97%, transparent);
animation: ldr-sun-cloud-rays 6s linear infinite;
}
.ldr-sun-cloud-cloud {
position: absolute;
left: 30%;
bottom: 18%;
width: calc(var(--s) * 0.74);
height: calc(var(--s) * 0.26);
border-radius: var(--s);
background: var(--c);
animation: ldr-sun-cloud-drift 3.2s ease-in-out infinite;
}
.ldr-sun-cloud-cloud::before,
.ldr-sun-cloud-cloud::after {
content: "";
position: absolute;
border-radius: 50%;
background: var(--c);
}
.ldr-sun-cloud-cloud::before {
left: 14%;
bottom: 40%;
width: calc(var(--s) * 0.28);
height: calc(var(--s) * 0.28);
}
.ldr-sun-cloud-cloud::after {
left: 38%;
bottom: 30%;
width: calc(var(--s) * 0.38);
height: calc(var(--s) * 0.38);
}
@keyframes ldr-sun-cloud-peek {
0%, 100% { transform: translate(calc(var(--s) * 0.08), calc(var(--s) * 0.08)) scale(0.9); }
50% { transform: translate(calc(var(--s) * -0.04), calc(var(--s) * -0.04)) scale(1); }
}
@keyframes ldr-sun-cloud-rays {
to { transform: rotate(360deg); }
}
@keyframes ldr-sun-cloud-drift {
0%, 100% { transform: translateX(calc(var(--s) * -0.03)); }
50% { transform: translateX(calc(var(--s) * 0.05)); }
}
@media (prefers-reduced-motion: reduce) {
.ldr-sun-cloud, .ldr-sun-cloud *, .ldr-sun-cloud::before, .ldr-sun-cloud::after, .ldr-sun-cloud *::before, .ldr-sun-cloud *::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.