react-rangeslider
raw JSON →A fast and lightweight React component that serves as a drop-in replacement for the HTML5 input range slider element. The package is currently at version 2.5.8, with a stable API focused on simplicity and performance. It provides a declarative slider with customizable orientation (horizontal/vertical), min/max values, step size, tooltip display, labels, and callbacks for value changes. The package includes default CSS styles and supports both controlled and uncontrolled usage. Compared to alternatives, it emphasizes minimal bundle size, no external dependencies aside from React, and a straightforward API. The project appears to be in maintenance mode with no recent updates, and peer dependencies are limited to React 0.14.x or 15.x, which may cause compatibility issues with newer React versions.
Common errors
error Module not found: Can't resolve 'react-rangeslider' ↓
error Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined. ↓
error Cannot read property 'prototype' of undefined ↓
error Invalid prop `value` of type `string` supplied to `Slider`, expected `number`. ↓
Warnings
breaking React peer dependency is limited to 0.14.x or 15.x. May not work with React 16+ or newer. ↓
gotcha The slider does not support controlled props like min, max, step updates after initial render; values are only read on mount. ↓
gotcha The component does not handle touch events properly on some mobile browsers, leading to sticky slider behavior. ↓
deprecated The UMD build is located at unpkg, but the library may not be actively maintained. ↓
Install
npm install react-range-slider1 yarn add react-range-slider1 pnpm add react-range-slider1 Imports
- Slider wrong
import { Slider } from 'react-rangeslider'correctimport Slider from 'react-rangeslider' - Slider wrong
var Slider = require('react-rangeslider').Slidercorrectvar Slider = require('react-rangeslider') - styles wrong
import styles from 'react-rangeslider/lib/index.css'correctimport 'react-rangeslider/lib/index.css'
Quickstart
import React, { Component } from 'react';
import Slider from 'react-rangeslider';
import 'react-rangeslider/lib/index.css';
class VolumeSlider extends Component {
constructor(props) {
super(props);
this.state = { volume: 0 };
}
handleOnChange = (value) => {
this.setState({ volume: value });
}
render() {
const { volume } = this.state;
return (
<Slider
value={volume}
orientation="vertical"
onChange={this.handleOnChange}
/>
);
}
}
export default VolumeSlider;