Click Ripple Effect Button Template

Add dynamic, tactile feedback to your buttons with this cool click ripple effect.

Inspired by Google's Material Design, this effect creates a circle that ripples out from the exact point of a user's click, providing an engaging and modern interaction.

Screenshot showing a ripple animation on a button when clicked.

Get Source Code Preview

About the Click Ripple Effect Button

The ripple effect is a popular micro-interaction that provides immediate and tangible feedback for a click or tap. It confirms to the user not only that their action was registered, but precisely *where* it was registered. This template achieves the effect with a combination of CSS and JavaScript: the JavaScript detects the click location and creates the ripple element, while CSS handles the element's appearance and animation.

Features

Code Breakdown

The CSS sets the button's position to relative and overflow to hidden, which is required in order to contain the ripple. The ripple itself is a span element that is created dynamically by JavaScript. It is styled to be a circle and is positioned absolutely within the button.

The JavaScript attaches a click event listener. When a click occurs, it calculates the cursor's coordinates relative to the button, creates a new element, sets its position using the calculated coordinates, and appends it to the button. The CSS animation then takes over. After the animation completes, the script removes the span from the DOM to keep the page clean.

Code

Here is the complete HTML, CSS, and JavaScript for the click ripple effect button.

View Output