
Adding a ripple effect to your website is one of the best ways to make your website feel modern and attractive to its users. Nowadays, Many popular websites use ripple click effect in their website to provide their users with visual feedback when users click links, buttons or other elements in the website. A well-made ripple click effect can improve user experience by providing smoother animation and a modern design.
From this tutorial, you will learn how to add a modern ripple click effect to your website just using pure CSS and JavaScript. In this tutorial, we will learn to add both the body and the button ripple effect with smooth animation, modern design and with dark mode support to your website. As this ripple click effect uses only pure CSS and lightweight JavaScript instead of relying on external libraries, it also doesn't affect your webpage's speed.
Whether you are building a personal blog, a modern Blogger template, a portfolio website or any other type of website, this ripple effect can provide a modern and professional touch to your website. Just by following the steps provided below, you can also add a ripple click effect to your website easily. So without wasting much time, let's check how it works and how we can implement this on your website.
Table of Contents
Live Ripple Effect Demo
View Demo
Features of This Ripple Effect
- Uses Pure CSS and JavaScript
- No external libraries used
- Added dark mode support
- Smooth Animation
- Very lightweight codes
How to Add This Ripple Effect to Your Website
- Go to your webpage HTML file (example: index.html). If you are using Blogger, go to your Blogger dashboard, then click the "Theme" option, then click the drop-down menu next to the "Customise" button, then click the "Edit HTML" option.
- Add the following CSS just above the
</head>tag and wrap it inside<style></style>. If you are using Blogger, paste the CSS just above]]></b:skin>. - Paste the following JavaScript just above the
</body>tag - Now save the changes we made in the HTML
Body Ripple Effect CSS
/* Body Ripple Effect (www.coshix.in) */.rpL{position:fixed;left:0;top:0;width:10px;height:10px;border-radius:50%;pointer-events:none;z-index:999999;transform:translate(-50%,-50%) scale(0);opacity:0;background:radial-gradient(circle,rgba(79,70,229,.62) 0%,rgba(37,99,235,.42) 36%,rgba(0,0,0,.12) 58%,transparent 78%);box-shadow:0 0 14px rgba(79,70,229,.32),0 0 24px rgba(37,99,235,.18);mix-blend-mode:multiply;will-change:transform,opacity}.rpL:after{content:"";position:absolute;inset:-1px;border-radius:50%;border:1.2px solid rgba(79,70,229,.4)}.rpL.a{animation:rA .42s cubic-bezier(.22,1,.36,1)}@keyframes rA{0%{opacity:1;transform:translate(-50%,-50%) scale(.2)}100%{opacity:0;transform:translate(-50%,-50%) scale(5.5)}}
/* Dark mode (Remove if not using) */.dark-mode .rpL{background:radial-gradient(circle,rgba(255,255,255,.82) 0%,rgba(147,197,253,.42) 34%,rgba(255,255,255,.12) 56%,transparent 78%);box-shadow:0 0 16px rgba(255,255,255,.22),0 0 26px rgba(147,197,253,.14);mix-blend-mode:screen}.dark-mode .rpL:after{border-color:rgba(255,255,255,.32)}
Button Ripple Effect CSS
/* Ripple Button (www.coshix.in) */.rpLb{margin-top:10px;margin-bottom:10px;position:relative;overflow:hidden;display:inline-flex;align-items:center;justify-content:center;padding:12px 18px;border:0;border-radius:30px;background:linear-gradient(135deg,#6366f1,#3b82f6);color:#fff;font-size:14px;cursor:pointer;-webkit-tap-highlight-color:transparent;box-shadow:0 10px 24px rgba(79,70,229,.22),inset 0 1px rgba(255,255,255,.18);transition:transform .16s cubic-bezier(.22,1,.36,1),box-shadow .22s ease}.rpLb:active{transform:scale(.985);box-shadow:0 5px 16px rgba(79,70,229,.18)}.br{position:absolute;left:0;top:0;width:14px;height:14px;border-radius:50%;pointer-events:none;transform:translate(-50%,-50%) scale(0);opacity:0;background:radial-gradient(circle,rgba(255,255,255,.92) 0%,rgba(255,255,255,.38) 40%,rgba(255,255,255,.1) 60%,transparent 78%);mix-blend-mode:screen;will-change:transform,opacity}.br.a{animation:bA .55s cubic-bezier(.22,1,.36,1)}@keyframes bA{0%{opacity:.95;transform:translate(-50%,-50%) scale(.2)}100%{opacity:0;transform:translate(-50%,-50%) scale(8.5)}}
Body Ripple Effect JavaScript
<script>/*<![CDATA[*//* Body Ripple Effect JS (www.coshix.in) */addEventListener("pointerdown",e=>{if(e.target.closest(".rpLb"))return;const r=document.createElement("div");r.className="rpL a";r.style.left=e.clientX+"px";r.style.top=e.clientY+"px";document.body.appendChild(r);r.onanimationend=()=>r.remove()},{passive:true});/*]]>*/</script>
Button Ripple Effect JavaScript
<script>/*<![CDATA[*//* Ripple Button JS (www.coshix.in) */document.querySelectorAll(".rpLb").forEach(b=>b.addEventListener("pointerdown",e=>{const r=document.createElement("span");r.className="br a";r.style.left=e.offsetX+"px";r.style.top=e.offsetY+"px";b.appendChild(r);r.onanimationend=()=>r.remove()},{passive:true}));/*]]>*/</script>
How This Ripple Effect Works
FAQ (Frequently Asked Questions)
Does this ripple effect affect website speed?
No, this ripple effect uses lightweight CSS and JavaScript
Does this work in Blogger?
Yes, this ripple effect works perfectly in Blogger websites
Can I use this ripple effect on buttons only?
Yes, you can use the button ripple effect separately.
Will this work on all modern browsers?
Yes, the ripple effect works on most modern browsers including Chrome, Edge and Firefox.