Polygon Cycle
A copy-paste morphing shapes component in pure HTML & CSS. Zero dependencies, framework-agnostic, MIT-licensed.
Morphing ShapesHTMLCSSany framework
Copy into your project
HTML
<!-- Polygon Cycle -->
<div class="nuda-ms2-polygon-cycle" role="img" aria-label="Shape cycling through triangle, square, pentagon and hexagon">
<span class="nuda-ms2-polygon-cycle__shape" aria-hidden="true"></span>
</div>CSS
.nuda-ms2-polygon-cycle {
display: flex;
align-items: center;
justify-content: center;
width: 110px;
height: 110px;
}
.nuda-ms2-polygon-cycle__shape {
width: 70px;
height: 70px;
background: linear-gradient(135deg,#e4ff54,#a3b830);
animation: _nuda-ms2PolygonCycle 6s ease-in-out infinite;
will-change: clip-path,transform;
}
@keyframes _nuda-ms2PolygonCycle {
0% {
clip-path: polygon(50% 0%,0% 100%,100% 100%);
transform: rotate(0deg);
}
25% {
clip-path: polygon(0 0,100% 0,100% 100%,0 100%);
transform: rotate(90deg);
}
50% {
clip-path: polygon(50% 0%,100% 38%,82% 100%,18% 100%,0% 38%);
transform: rotate(180deg);
}
75% {
clip-path: polygon(25% 0%,75% 0%,100% 50%,75% 100%,25% 100%,0% 50%);
transform: rotate(270deg);
}
100% {
clip-path: polygon(50% 0%,0% 100%,100% 100%);
transform: rotate(360deg);
}
}
@media (prefers-reduced-motion:reduce) {
.nuda-ms2-polygon-cycle__shape {
animation: none;
clip-path: polygon(25% 0%,75% 0%,100% 50%,75% 100%,25% 100%,0% 50%);
}
}
How to use Polygon Cycle
Paste the HTML where you need it and the CSS into a global stylesheet (or a <style> tag). Every class is prefixed nuda- so it never collides with Tailwind or your own styles. Tweak the CSS custom properties to match your design system.
Works in React, Vue, Svelte, Astro, Next.js, Nuxt, Laravel Blade, Django, Rails — or a single .html file. No npm install, no build step.