Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-compare-image

Package Overview
Dependencies
Maintainers
1
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-compare-image

React component to compare two images using slider.

  • 3.4.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
8K
increased by6.63%
Maintainers
1
Weekly downloads
 
Created
Source

React Compare Image

All Contributors

Buy Me A Coffee

Simple React component to compare two images using slider.

img

NOTE: Vue.js Version is also available!

Demo & Sample codes

Demo & Sample codes

Features

  • Simple
  • Responsive (always fit to the parent width)
  • Horizontal & Vertical comparison

How to use

yarn add react-compare-image
// or
npm install --save react-compare-image

Note: Version 1 or later works only with React16.8 or later. Use version 0 instead.

import ReactCompareImage from 'react-compare-image';

<ReactCompareImage leftImage="image1.jpg" rightImage="image2.jpg" />;

Props

Prop (* required)typedefaultdescription
aspectRatio'taller' or 'wider''taller'Which to choose if the aspect ratios of the images are different
handleelementnullCustom handle element. Just pass <React.Fragment /> if you want to remove handle.
handleSizenumber (px)40diameter of slider handle (by pixel)
hoverbooleanfalseWhether to slide at hover
leftImage *stringnullleft image's url
leftImageAltstring''alt props for left image
leftImageCssobject{}Additional css for left image
leftImageLabelstringnullLabel for the image (e.g. before)
onSliderPositionChangefunctionnullCallback function called each time the slider changes. The position (0 to 1) of the slider is passed as arg
rightImage *stringnullright image's url
rightImageAltstring''alt props for right image
rightImageCssobject{}Additional css for right image
rightImageLabelstringnullLabel for the image (e.g. after)
skeletonelementnullElement displayed while image is loading
sliderLineColorstring'#ffffff'line color of slider
sliderLineWidthnumber (px)2line width of slider (by pixel)
sliderPositionPercentagenumber (float)0.5Default line position (from 0 to 1)
verticalbooleanfalseCompare images vertically instead of horizontally. The left image is on the top and the right image is on the bottom.

Supported browzer

Latest modern browsers(Chrome, Safari, Firefox, Edge)

Keywords

FAQs

Package last updated on 14 Apr 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc