Menu to Close
A copy-paste animated icons component in pure HTML, CSS & vanilla JS. Zero dependencies, framework-agnostic, MIT-licensed.
Animated IconsHTMLCSSJavaScriptany framework
Copy into your project
HTML
<button class="nuda-icon-burger" type="button" aria-label="Toggle menu" aria-pressed="false">
<svg class="nuda-icon-burger__svg" viewBox="0 0 24 24" aria-hidden="true">
<line class="nuda-icon-burger__top" x1="3" y1="6" x2="21" y2="6" />
<line class="nuda-icon-burger__mid" x1="3" y1="12" x2="21" y2="12" />
<line class="nuda-icon-burger__bot" x1="3" y1="18" x2="21" y2="18" />
</svg>
</button>CSS
/* Menu to Close
Three bars rotate/collapse into an X. Active state lights up lime.
GPU-only: transform + opacity. Customize: --icon-accent */
.nuda-icon-burger {
--icon-accent: #e4ff54;
display: inline-flex;
align-items: center;
justify-content: center;
width: 44px;
height: 44px;
background: #09090b;
border: 1px solid rgba(255, 255, 255, 0.1);
border-radius: 10px;
color: #fafafa;
cursor: pointer;
transition: border-color 0.25s, color 0.25s;
}
.nuda-icon-burger:hover,
.nuda-icon-burger:focus-visible {
border-color: rgba(228, 255, 84, 0.4);
outline: none;
}
.nuda-icon-burger:focus-visible {
box-shadow: 0 0 0 2px rgba(228, 255, 84, 0.5);
}
.nuda-icon-burger[aria-pressed="true"] { color: var(--icon-accent); }
.nuda-icon-burger__svg {
width: 24px;
height: 24px;
stroke: currentColor;
stroke-width: 2;
stroke-linecap: round;
fill: none;
}
.nuda-icon-burger__svg line {
transition: transform 0.3s cubic-bezier(0.4, 0.2, 0.2, 1), opacity 0.2s;
transform-origin: center;
will-change: transform, opacity;
}
.nuda-icon-burger[aria-pressed="true"] .nuda-icon-burger__top {
transform: translateY(6px) rotate(45deg);
}
.nuda-icon-burger[aria-pressed="true"] .nuda-icon-burger__mid {
opacity: 0;
transform: scaleX(0);
}
.nuda-icon-burger[aria-pressed="true"] .nuda-icon-burger__bot {
transform: translateY(-6px) rotate(-45deg);
}
@media (prefers-reduced-motion: reduce) {
.nuda-icon-burger__svg line { transition: none; }
}JavaScript
/* Menu to Close — vanilla JS
Flips aria-pressed; CSS handles the morph. */
(function () {
document.querySelectorAll(".nuda-icon-burger").forEach(function (btn) {
btn.addEventListener("click", function () {
var pressed = btn.getAttribute("aria-pressed") === "true";
btn.setAttribute("aria-pressed", String(!pressed));
});
});
})();How to use Menu to Close
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.