请选择 进入手机版 | 继续访问电脑版
  • 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

whoisandy/react-rangeslider: A lightweight responsive react range slider compone ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

whoisandy/react-rangeslider

开源软件地址:

https://github.com/whoisandy/react-rangeslider

开源编程语言:

JavaScript 76.7%

开源软件介绍:

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

Prop Type Default Description
min number 0 minimum value the slider can hold
max number 100 maximum value the slider can hold
step number 1 step in which increments/decrements have to be made
value number current value of the slider
orientation string horizontal orientation of the slider
tooltip boolean true show or hide tooltip
reverse boolean false reverse direction of vertical slider (top-bottom)
labels object {} object containing key-value pairs. { 0: 'Low', 50: 'Medium', 100: 'High'}
handleLabel string '' string label to appear inside slider handles
format function function to format and display the value in label or tooltip
onChangeStart function function gets called whenever the user starts dragging the slider handle
onChange function function gets called whenever the slider handle is being dragged or clicked
onChangeComplete function function 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




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap