Cursor: Floating target: Step-by-step tutorial

Matt Perry
In this tutorial, we're going to build the Cursor: Floating target example step-by-step.
This example is rated 3/5 difficulty, which means we assume you're already quite familiar with Motion (and JavaScript in general).
Here's a live demo of the example we're going to be creating:
Checking Motion+ status…
The Cursor: Floating target 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?
Introduction
The Floating Target example creates a rotating button that reacts to your cursor with a smooth spring animation. As well as creating a custom usePointerReaction
hook, we'll use several Motion APIs:
The
usePointerPosition
hook from Motion+ for tracking cursor position.The
useTransform
anduseSpring
hooks for smooth cursor following.The
useAnimate
hook for continuous rotation.The
Cursor
component from Motion+ for custom cursor effects.Motion variants for hover and press animations.