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

react-compare-slider

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-compare-slider

Comparison slider for React components. Supports images, videos... and everything else.

  • 1.0.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
40K
increased by3.41%
Maintainers
1
Weekly downloads
 
Created
Source

React Compare Slider

Compare two components, side-by-side or top-to-toe.

License MIT NPM package Bundle size
Build Status Coverage Demos

Features

  • Supports responsive images, videos, any React components
  • Supports landscape and portrait orientations
  • Simple API
  • Unopinionated & fully customizable – optionally use your own components and styles
  • Responsive, fluid
  • Works in IE11+
  • Teeny-tiny, only one ponyfill dependency
  • Type safe

Demo

See Storybook for documentation and demos.

Also see the local example folder for standalone demos.

Usage

Install

yarn add react-compare-slider
# OR
npm install react-compare-slider

Basic Image Usage

You may use ReactCompareSliderImage to render images or use your own custom components.

import { ReactCompareSlider, ReactCompareSliderImage } from 'react-compare-slider';

<ReactCompareSlider
  itemOne={<ReactCompareSliderImage src="..." srcSet="..." alt="Image one" />}
  itemTwo={<ReactCompareSliderImage src="..." srcSet="..." alt="Image two" />}
/>

See the Image Playground to experiment with images using the "Knobs" tab.

Advanced Usage

See the docs for advanced examples.

Props

PropTypeRequiredDefault valueDescription
handleReactNodeundefinedCustom handle component
itemOneReactNodeundefinedFirst component to show in slider
itemTwoReactNodeundefinedSecond component to show in slider
onPositionChangefunctionundefinedCallback on position change, returns current position as argument (position) => { ... }
positionnumber50Initial percentage position of divide (0-100)
portraitbooleanundefinedWhether to use portrait orientation

See the API docs for more information.

Extending

Custom Components

Custom components can apply the same base styles as ReactCompareSliderImage by using the styleFitContainer CSS utility.

See the styleFitContainer docs for more information.

Images

See the Images docs for more information.

Requirements

  • React 16.8+

Notes

Bootstrapped with TSDX.

Keywords

FAQs

Package last updated on 07 Jun 2020

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