Skip to content

Plus 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-plus" type="button" aria-label="Add" aria-pressed="false">
  <svg class="nuda-icon-plus__svg" viewBox="0 0 24 24" aria-hidden="true">
    <line class="nuda-icon-plus__h" x1="5"  y1="12" x2="19" y2="12" />
    <line class="nuda-icon-plus__v" x1="12" y1="5"  x2="12" y2="19" />
  </svg>
</button>
CSS
/* Plus to Close
   The whole glyph rotates 135deg; the two strokes shrink slightly so the X
   reads balanced. GPU-only: transform. Customize: --icon-accent */

.nuda-icon-plus {
  --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-plus:hover,
.nuda-icon-plus:focus-visible {
  border-color: rgba(228, 255, 84, 0.4);
  outline: none;
}

.nuda-icon-plus:focus-visible {
  box-shadow: 0 0 0 2px rgba(228, 255, 84, 0.5);
}

.nuda-icon-plus[aria-pressed="true"] { color: var(--icon-accent); }

.nuda-icon-plus__svg {
  width: 24px;
  height: 24px;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  fill: none;
  transition: transform 0.4s cubic-bezier(0.4, 0.2, 0.2, 1.2);
  transform-origin: center;
  will-change: transform;
}

.nuda-icon-plus[aria-pressed="true"] .nuda-icon-plus__svg {
  transform: rotate(135deg);
}

.nuda-icon-plus__svg line {
  transition: transform 0.4s cubic-bezier(0.4, 0.2, 0.2, 1.2);
  transform-origin: center;
}

.nuda-icon-plus[aria-pressed="true"] .nuda-icon-plus__h { transform: scaleX(0.72); }
.nuda-icon-plus[aria-pressed="true"] .nuda-icon-plus__v { transform: scaleY(0.72); }

@media (prefers-reduced-motion: reduce) {
  .nuda-icon-plus__svg,
  .nuda-icon-plus__svg line { transition: none; }
}
JavaScript
/* Plus to Close — vanilla JS
   Flips aria-pressed and label; CSS rotates the glyph. */

(function () {
  document.querySelectorAll(".nuda-icon-plus").forEach(function (btn) {
    btn.addEventListener("click", function () {
      var open = btn.getAttribute("aria-pressed") !== "true";
      btn.setAttribute("aria-pressed", String(open));
      btn.setAttribute("aria-label", open ? "Close" : "Add");
    });
  });
})();

How to use Plus 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.

More animated icons components

← Browse all NudaUI components