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

reactrangeslider

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

reactrangeslider

A range slider component for React.

  • 3.0.6
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
78
increased by5.41%
Maintainers
1
Weekly downloads
 
Created
Source

React Sliders

An collection of elegant slider components for React. Demo Page.

Installing

The library is available as npm package.

npm install reactrangeslider

Using The component

The component is easy to use. Import the library and add the component to your JSX:

import React from 'react';
import Slider from 'range-sliders';

const MyPage = () =>
  <div>
    <Slider />
  </div>;

Small cart in header

An example of uncontrolled slider with single handle, defaultValue and step passed in props:

import React from 'react';
import RangeSlider from 'reactrangeslider';

const MyPage = () =>
  <div>
    <Slider defaultValue={20} step={ 5 } />
  </div>;

An example of controlled range slider with two handles, value and step passed in props:

import React from 'react';
import RangeSlider from 'reactrangeslider';

// value={ start: 20, end: 80 }
const MyPage = (value, onChange) =>
  <div>
    <RangeSlider
      value={ value }
      onChange={ onChange }
      min={ 20 }
      max={ 100 }
      step={ 5 }
    />
  </div>;

Check docs for more examples.

List of properties supported

OptionDescription
idid of the root div element
namename of the root div element
minminimum value in the range
maxmaximum value in the range
stepamount by which the position of slider will change in one movement
defaultValueit is used to initialize uncontrolled components
valueit is used to set value in a controlled component
onChangethe function is executed whenever the value changes
afterChangethe function is executed after the user has stopped moving the slider
disabledproperty used to disable component, disable component can not even receive focus
readOnlyproperty used to make component readOnly, it can still be focused
tabIndexthis is used to set the tabIndex of handles which are moved to change value of slider

Custom styling

Styling of Range Slider is highly customizable. It supports styling using both inline styles and classes. Internally the libary used inline styles, I have preferred that for ease of installation for users.

If inline styles are used for styling, the inline styles passed to it will override the defaults. If classes are used for styling, you will be required to use !important to override corresponding default inline style.

Style PropertyDescription
wrapperStylestyle applied to wrapper div element
trackStylestyle applied to track
disabledTrackStylestyle applied to track of disabled component
highlightedTrackStylestyle applied to highlighted track
disabledHighlightedTrackStylestyle applied to highlighted track of disabled component
handleStylestyle applied to handle
focusedHandleStylestyle applied to focused handle
hoveredHandleStylestyle applied to hovered handle
activeHandleStylestyle applied to active handle
disabledHandleStylestyle applied to disabled handle
Class NameDescription
wrapperClassNameclass applied to wrapper div element
handleClassName / disabledHandleClassNameeither of these classes is applied to the handle depending on whether its enabled or disabled
trackClassName / highlightedTrackClassNameeither of these classes is applied to the track depending on whether its enabled or disabled
highlightedTrackClassName / disabledHighlightedTrackClassNameeither of these classes is applied to the highlighted handle depending on whether its enabled or disabled
Styles applied to highlighted track are applicable only to Reage Slider with two handles and highlighted area between them.

Device support

Range Slider is responsive to different sizes and resolutions. Its responsive to mouse, keyboard and touch events.

Future plans

Making it a complete range of slider components with addition of components like vertical slider, vertical range slider, etc motivation.

License

MIT.

Keywords

FAQs

Package last updated on 18 Sep 2016

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