Motion+

Hold to confirm

A Motion example showing long-press interaction. The button's events update a progress motion value that drives multiple animations of other motion values.

Time
5 min
Difficulty
Intermediate
Access
Motion+
>Live exampleOpen in new tab

Introduction

The Hold to confirm example shows an interactive button that requires a long press to trigger an action. This pattern is commonly used for destructive or important actions, giving users time to reconsider before completing the action.

This example uses several Motion APIs working together. The press function detects when the button is held down, the animate function drives the progress animation, motionValue stores the animation progress, mapValue transforms the progress into different visual properties, and styleEffect automatically updates element styles as the Motion value changes.

The example creates a sophisticated multi-element animation from a single progress value. When you press and hold the button, a circular progress ring draws around it, the button scales down slightly, and a glowing background slides into view. All these animations are driven by one Motion value that updates as you hold the button.