@appigram/react-rangeslider

中文文档
2.2.24发布于 2026/06/12MITCommonJS近 30 天下载 6215

A lightweight react component that acts as a HTML5 input range slider polyfill

原始使用文档
文档目录9 节
  1. Installation
  2. Getting Started
  3. Basic Example
  4. API
  5. Component
  6. Props
  7. Development
  8. Issues
  9. License

react-rangeslider

A fast & lightweight react component as a drop in replacement for HTML5 input range slider element.

Installation

Using npm (use --save to include it in your package.json)

$ npm install react-rangeslider --save

Using yarn (this command also adds react-rangeslider to your package.json dependencies)

$ yarn add react-rangeslider

Getting Started

React-Rangeslider is bundled with a slider component & default styles which can be overridden depending on your design requirements.

With a module bundler like webpack that supports either CommonJS or ES2015 modules, use as you would anything else:

// Using an ES6 transpiler like Babel
import Slider from 'react-rangeslider'

// To include the default styles
import 'react-rangeslider/lib/index.css'

// Not using an ES6 transpiler
var Slider = require('react-rangeslider')

The UMD build is also available on unpkg:

<script src="https://unpkg.com/react-rangeslider/umd/rangeslider.min.js"></script>

You can find the library on window.ReactRangeslider. Optionally you can drop in the default styles by adding the stylesheet.

<link rel="stylesheet" href="https://unpkg.com/react-rangeslider/umd/rangeslider.min.css" />

Check out docs & examples.

Basic Example

import React, { Component } from 'react'
import Slider from 'react-rangeslider'

class VolumeSlider extends Component {
  constructor(props, context) {
    super(props, context)
    this.state = {
      volume: 0
    }
  }

  handleOnChange = (value) => {
    this.setState({
      volume: value
    })
  }

  render() {
    let { volume } = this.state
    return (
      <Slider
        value={volume}
        orientation="vertical"
        onChange={this.handleOnChange}
      />
    )
  }
}

API

Rangeslider is bundled as a single component, that accepts data and callbacks only as props.

Component

import Slider from 'react-rangeslider'

// inside render
<Slider
  min={Number}
  max={Number}
  step={Number}
  value={Number}
  orientation={String}
  reverse={Boolean}
  tooltip={Boolean}
  labels={Object}
  handleLabel={String}
  format={Function}
  onChangeStart={Function}
  onChange={Function}
  onChangeComplete={Function}
/>

Props

PropTypeDefaultDescription
minnumber0minimum value the slider can hold
maxnumber100maximum value the slider can hold
stepnumber1step in which increments/decrements have to be made
valuenumbercurrent value of the slider
orientationstringhorizontalorientation of the slider
tooltipbooleantrueshow or hide tooltip
reversebooleanfalsereverse direction of vertical slider (top-bottom)
labelsobject{}object containing key-value pairs. { 0: 'Low', 50: 'Medium', 100: 'High'}
handleLabelstring''string label to appear inside slider handles
formatfunctionfunction to format and display the value in label or tooltip
onChangeStartfunctionfunction gets called whenever the user starts dragging the slider handle
onChangefunctionfunction gets called whenever the slider handle is being dragged or clicked
onChangeCompletefunctionfunction gets called whenever the user stops dragging the slider handle.

Development

To work on the project locally, you need to pull its dependencies and run npm start.

$ npm install
$ npm start

Issues

Feel free to contribute. Submit a Pull Request or open an issue for further discussion.

License

MIT

版本与发布记录

@appigram/react-rangeslider 共发布 22 个版本,首次发布于 2019/08/05;过去 12 个月发布了 2 个版本。

版本发布日期距今
2.2.24latest2026/06/124 个月前
2.2.232026/01/089 个月前
2.2.222024/04/292 年前
2.2.212023/09/043 年前
2.2.192023/03/033 年前
2.2.182022/10/294 年前

关于 @appigram/react-rangeslider 的常见问题

@appigram/react-rangeslider 是什么?

A lightweight react component that acts as a HTML5 input range slider polyfill

如何安装 @appigram/react-rangeslider?

在项目目录运行 npm install @appigram/react-rangeslider,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(*)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@appigram/react-rangeslider 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/appigram__react-rangeslider 是否存在。

@appigram/react-rangeslider 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@appigram/react-rangeslider 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=14。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@appigram/react-rangeslider 可以商用吗?

@appigram/react-rangeslider 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@appigram/react-rangeslider 的下载量有多少?

根据 npm 官方下载统计,@appigram/react-rangeslider 在 2026/10/07 – 2026/11/05 这 30 天内被下载 6,215 次,日均约 207 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@appigram/react-rangeslider 还在维护吗?

最新版本 2.2.24 发布于 2026/06/12(4 个月前);至今共发布 22 个版本,其中过去 12 个月发布了 2 个;首次发布于 2019/08/05。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。