Material Design: Ripple: Step-by-step tutorial

Matt Perry

In this tutorial, we're going to build the Material Design: Ripple example step-by-step.

This example is rated 2/5 difficulty, which means we'll spend some time explaining the Motion APIs we've chosen to use, but it assumes familiarity with JavaScript as a language.

Here's a live demo of the example we're going to be creating:

Loading...

Checking Motion+ status…

The Material Design: Ripple tutorial

is exclusive to Motion+

290+ examples & 35+ tutorials

Premium APIs

Visual editor for VS Code

alpha

Discord community

Early access

Lifetime updates

One-time payment, lifetime updates

Already joined?

The Material Design Ripple example recreates the touch ripple effect found in Google's Material Design components. The ripple creates visual feedback when users interact with a button, expanding outward from the point of touch.

In this tutorial, we'll use two Motion APIs: animate to create the ripple animations and hover to handle button hover states.

Get started

Let's start with a simple button and the basic HTML structure we need for the ripple effect.

<button class="md-button">
    Click me<span class="ripple-container" aria-hidden></span>
</button>

<script type="module">
    // We'll add our JavaScript here
</script>

<style>
    /** Copy from example source */
</style>

The key to our ripple setup is the .ripple-container element inside the button. This acts as a clipping mask - any ripples we create will be contained within the button's rounded corners. We use pointer-events: none so clicks pass through to the button itself.

Motion is supported by the best in the industry.

Stay in the loop

Subscribe for the latest news & updates.

Stay in the loop

Subscribe for the latest news & updates.

Stay in the loop

Subscribe for the latest news & updates.