Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

react-slider-kit is going to be a comprehensive solution to slider feature in react.

License

NotificationsYou must be signed in to change notification settings

M-Izadmehr/react-slider-kit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

N|Solid

react-slider-kit is going to be a comprehensive solution to slider feature in react. This component was originally inspired by dribble concept designThe Range Slider Component.

This slider components is going to include:

  • 1D and 2D sliders
  • Single and range sliders (in progress)
  • Horizontal and vertical sliders

Demo

The working demo of this component can be find athttps://m-izadmehr.github.io/react-slider-kit/. An image of the original dribble design is shown below:

N|Solid


Installation

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

$ npm install react-slider-kit --save

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

$ yarn add react-slider-kit

Getting Started

react-slider-kit is going to be a package of different sliders. In order to use a slider with a module bundler like webpack that supports either CommonJS or ES2015 modules, use as you would anything else:

// Using an ES6 transpiler like Babelimport{}from'react-rangeslider'// Not using an ES6 transpilervarSlider=require('react-rangeslider')

Basic Example

importReact,{Component}from'react'import{SingleSlider}from'react-slider-kit';exportdefaultclassSimpleExampleextendsComponent{constructor(props,context){super(props,context)this.state={value:0}}handleOnChange=(value)=>{this.setState({value:value})}render(){return(<SingleSlidermin={0}max={100}step={20}start={80}onChangeStart={()=>console.log('start drag')}onChange={(value)=>console.log('drag value: ',value)}onChangeComplete={this.handleOnChange}/>)}}

API

React-Slider-Kit is bundled as a combination of multiple components, and by default the single slider is imported.

Component

import{SingleSlider}from'react-slider-kit';// inside render<SingleSlidermin={Number}max={Number}step={Number}start={Number}sliderTo={Number}prefix={String}postfix={String}labels={Array}sticky={Boolean}tooltip={String}orientation={String}// chart configschartData={Array}chartTooltip={Boolean}chartLength={Number}// methodsonChangeStart={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
startnumber0starting value of slider
sliderTonumberundefinedused to change the value of slider manually (componentWillReceiveProps is listening for changes in this value)
tooltipstring'always'controls when slider tooltip is shown (always/onClick/never)
prefixstring''prefix in tooltip label (eg. '$')
postfixstring''postfix in tooltip label (eg. 'kg')
labelsarray[]custom labels to show on slider (eg.[{x:0,val:'Start'}, {x:50,val:'Middle'},]
stickybooleanfalsecontrols whether slider handle can move smoothly or it can only sit on step values
orientationstring'horizontal'slider orientation (eg.horizontal,vertical)
chartDataarray-used for showing 2D frequency graph on the slider (eg.[{ y: 0 }, { y: 0.1 }, { y: 1 }, { y: 1.5 }, { y: 3 }])
chartTooltipbooleanfalsecontrols whether chart tooltip is shown on hover on data points
chartLengthnumber200chart height (width) of chart in horizontal (vertical) orientation
onChangeStartfunction-function called on starting to drag slider
onChangefunction-function called during moving slider(on every pixel)
onChangeCompletefunction-function called after finishing slider move (used to set slider value on state)

License

MIT

About

react-slider-kit is going to be a comprehensive solution to slider feature in react.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp