Learn how to build a spotlight effect by animating a radial gradient that follows the mouse cursor. Built with React, Framer Motion and Tailwind CSS.
๐ LINKS
Code: https://buildui.com/recipes/spotlight
Motion values: https://www.framer.com/motion/motionvalue/
๐ TIMESTAMPS
0:00 โ Intro
0:21 โ Radial gradient
2:55 โ Tracking the mouse position
7:50 โ Updating the gradient position with React state
9:26 โ Too many re-renders
10:37 โ Refactoring to motion values
13:41 โ Revealing the spotlight on hover
15:30 โ Adding a border glow
16:59 โย Final demo
Download
0 formats
No download links available.
Animating a radial gradient with Framer Motion | NatokHD