Go to homepage

Projects /

Image Comparison Slider

A draggable image slider used to compare two versions of the same image.

View Demo

Dependencies

All components are compatible with CodyFrame, Tailwind CSS or any other CSS framework.

To use this component, include the following dependencies:

How To

The Image Comparison Slider component is used to compare two images (for example the before/after of the same object or a photo and its edited version).

A handle element can be dragged to change the size of the modified image (visible above the original one).

The component is keyboard accessible: once the handle is in focus, the next/prev arrow keys can be used to increase/reduce the width of the modified image.

Dynamic Initialization #

If your slider is dynamically added to your page, you can initialize it using the ComparisonSlider object:

var comparisonSlider = document.getElementsByClassName('js-compare-slider');
new ComparisonSlider(comparisonSlider[0]);

🌅 Demo photo by Anita Austvika on Unsplash.

Categories

Bug Report & Feedback

Component Github page ↗

Level up your CSS skills

Each month we email a 1-minute CSS tutorial to 20K developers

Awesome! We just sent you a confirmation link by email

Error - please try again or contact us

Your email address is already subscribed

Project duplicated

Project created

Globals imported

There was an error while trying to export your project. Please try again or contact us.