Image reveal slider
An example of creating an interactive image comparison slider with Motion for React.
Introduction
The Image reveal slider example shows how to create an interactive slider that reveals a color image from its grayscale version. The same basic pattern can be used for comparisons between any two images.
We'll learn how to make this UI both with pointer and keyboard operation.
To do so, we'll use several key Motion APIs:
- The
motioncomponent to create animated elements useMotionValueto track the slider positionuseTransformto convert position values into visual properties- The
dragprop for interactive dragging animatefor triggering the keyboard-driven animations
