One shape turns from triangle to square to pentagon to hexagon and back, rotating a quarter turn each time. Every clip-path polygon has six points so the browser can tween between them.
Also known as: shape morph loader, clip-path morph animation, shape shifting loader.
<div class="ldr-polygon-morph" role="status" aria-label="Loading"></div>
.ldr-polygon-morph {
--s: var(--ldr-size, 48px);
--c: var(--ldr-color, #3b82f6);
width: calc(var(--s) * 0.9);
height: calc(var(--s) * 0.9);
margin: calc(var(--s) * 0.05);
background: var(--c);
animation: ldr-polygon-morph-shift 3.2s cubic-bezier(0.7, 0, 0.3, 1) infinite;
}
@keyframes ldr-polygon-morph-shift {
0%, 12% {
transform: rotate(0deg);
clip-path: polygon(50% 11%, 72.5% 50%, 95% 89%, 50% 89%, 5% 89%, 27.5% 50%);
}
25%, 37% {
transform: rotate(90deg);
clip-path: polygon(50% 12%, 88% 12%, 88% 88%, 50% 88%, 12% 88%, 12% 12%);
}
50%, 62% {
transform: rotate(180deg);
clip-path: polygon(50% 8.4%, 93.75% 40.2%, 77% 91.6%, 50% 91.6%, 23% 91.6%, 6.25% 40.2%);
}
75%, 87% {
transform: rotate(270deg);
clip-path: polygon(50% 6%, 88.1% 28%, 88.1% 72%, 50% 94%, 11.9% 72%, 11.9% 28%);
}
100% {
transform: rotate(360deg);
clip-path: polygon(50% 11%, 72.5% 50%, 95% 89%, 50% 89%, 5% 89%, 27.5% 50%);
}
}
@media (prefers-reduced-motion: reduce) {
.ldr-polygon-morph, .ldr-polygon-morph *, .ldr-polygon-morph::before, .ldr-polygon-morph::after, .ldr-polygon-morph *::before, .ldr-polygon-morph *::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.