Ripple Click
A copy-paste buttons component in pure HTML, CSS & vanilla JS. Zero dependencies, framework-agnostic, MIT-licensed.
ButtonsHTMLCSSJavaScriptany framework
Copy into your project
HTML
<!-- Ripple Click — material-style ripple on click -->
<button class="nuda-ripple">Ripple Click</button>CSS
/* ── Ripple Click ────────────────────────────────────────────
Customize:
--nuda-rp-bg : button background
--nuda-rp-clr : text color
--nuda-rp-ripple : ripple color (use semi-transparent)
--nuda-rp-speed : ripple expand duration
──────────────────────────────────────────────────────────── */
.nuda-ripple {
--nuda-rp-bg: #6366f1;
--nuda-rp-clr: #fff;
--nuda-rp-ripple: rgba(255, 255, 255, 0.4);
--nuda-rp-speed: 0.6s;
position: relative;
overflow: hidden;
padding: 12px 32px;
font-size: 1rem;
font-weight: 600;
color: var(--nuda-rp-clr);
background: var(--nuda-rp-bg);
border: none;
border-radius: 8px;
cursor: pointer;
}
.nuda-ripple__circle {
position: absolute;
border-radius: 50%;
background: var(--nuda-rp-ripple);
width: 40px;
height: 40px;
margin-top: -20px;
margin-left: -20px;
transform: scale(0);
animation: nuda-ripple-expand var(--nuda-rp-speed) ease-out forwards;
pointer-events: none;
}
@keyframes nuda-ripple-expand {
to {
transform: scale(4);
opacity: 0;
}
}
/* ── Accessibility ──────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
.nuda-ripple__circle {
animation: none;
display: none;
}
}JavaScript
/* ── Ripple Click — vanilla JS ───────────────────────────────
Creates a ripple span at the click position.
Respects prefers-reduced-motion.
──────────────────────────────────────────────────────────── */
;(function () {
if (window.matchMedia("(prefers-reduced-motion: reduce)").matches) return;
document.querySelectorAll(".nuda-ripple").forEach(function (btn) {
btn.addEventListener("click", function (e) {
var rect = btn.getBoundingClientRect();
var circle = document.createElement("span");
circle.classList.add("nuda-ripple__circle");
circle.style.left = (e.clientX - rect.left) + "px";
circle.style.top = (e.clientY - rect.top) + "px";
btn.appendChild(circle);
circle.addEventListener("animationend", function () {
circle.remove();
});
});
});
})();How to use Ripple Click
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.