Skip to content
roguelite labsAnthony Spezzano ↗
motion/image-comparison

Image Comparison

Before/after drag slider. Clip the left panel to the drag position. Works with any React children.

Use and inspectUse this when the motion supports the surrounding content. Connect callbacks and state to your app, keep the reset preview as a local demonstration, and add a reduced-motion fallback for movement or looping. The preview is synthetic; it does not call a backend.Next: inspect the source below and replace the demo inputs with your own data.
Image ComparisonBefore/after drag slider. Clip the left panel to the drag position. Works with any React children.

Props

PropTypeDefaultDescription
beforerequiredReactNodeBefore panel content
afterrequiredReactNodeAfter panel content
defaultPosnumber50Initial slider position (0–100)