• Stars
    star
    115
  • Rank 305,916 (Top 7 %)
  • Language
    JavaScript
  • Created over 8 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

React range slider component.

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

Option Description
id id of the root div element
name name of the root div element
min minimum value in the range
max maximum value in the range
step amount by which the position of slider will change in one movement
defaultValue it is used to initialize uncontrolled components
value it is used to set value in a controlled component
onChange the function is executed whenever the value changes
afterChange the function is executed after the user has stopped moving the slider
disabled property used to disable component, disable component can not even receive focus
readOnly property used to make component readOnly, it can still be focused
tabIndex this 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 Property Description
wrapperStyle style applied to wrapper div element
trackStyle style applied to track
disabledTrackStyle style applied to track of disabled component
highlightedTrackStyle style applied to highlighted track
disabledHighlightedTrackStyle style applied to highlighted track of disabled component
handleStyle style applied to handle
focusedHandleStyle style applied to focused handle
hoveredHandleStyle style applied to hovered handle
activeHandleStyle style applied to active handle
disabledHandleStyle style applied to disabled handle
Class Name Description
wrapperClassName class applied to wrapper div element
handleClassName / disabledHandleClassName either of these classes is applied to the handle depending on whether its enabled or disabled
trackClassName / highlightedTrackClassName either of these classes is applied to the track depending on whether its enabled or disabled
highlightedTrackClassName / disabledHighlightedTrackClassName either 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.

More Repositories

1

react-draft-wysiwyg

A Wysiwyg editor build on top of ReactJS and DraftJS. https://jpuri.github.io/react-draft-wysiwyg
JavaScript
6,358
star
2

draftjs-to-html

Library for converting Draftjs editor content state to HTML
JavaScript
315
star
3

draftjs-utils

An collection of useful utility functions for DraftJS.
JavaScript
285
star
4

html-to-draftjs

HTML
158
star
5

draftjs-to-markdown

JavaScript
62
star
6

GraphQL-Typescript-Starter

React Node GraphQL TypeScript - Starter Kit
TypeScript
44
star
7

react-component-stores

A simplified and powerful state management library for React applications.
JavaScript
21
star
8

react-simplified-boilerplate

A simplified boilerplate for my React projects
JavaScript
7
star
9

rustoli

Programming problems solved using Rust programming language
Rust
5
star
10

defi_yield_farming

DEFI yield farming dapp using chainlink price feeds
JavaScript
5
star
11

reason-places

A single page web application build using ReasonML
JavaScript
5
star
12

Solidity-Examples

Example solidity contracts
Solidity
3
star
13

solom

Articles about solidity
3
star
14

reason-tictactoe

Simple game of Tic Tac Toe made using ReasonML
OCaml
3
star
15

Election-DAPP

Election is simple DAPP which allow users to cast votes. It has some rules built on top of it like a user can cast only 1 vote, etc.
JavaScript
2
star
16

Runup

Runup token is implementation of ERC-20 token ground up (without using any library).
JavaScript
2
star
17

DaddaNFT

NFT minting
JavaScript
2
star
18

token_price_link

Obtaining latest token prices using chainlink blockchain
JavaScript
2
star
19

VR

VR and 2D Experiments
JavaScript
2
star
20

hub-poc

HTML
1
star
21

Learning-Reason

1
star
22

react-prosemirror

JavaScript
1
star
23

sanity-gatsby-blog

Blog with Gatsby
JavaScript
1
star
24

humble-site

CSS
1
star