• Stars
    star
    2,962
  • Rank 15,296 (Top 0.4 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 9 years ago
  • Updated about 1 year ago

Reviews

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

Repository Details

React Slider

rc-slider

Slider UI component for React

NPM version dumi build status Test coverage Dependencies DevDependencies npm download bundle size

Install

rc-slider

Example

npm start and then go to http://localhost:8000

Online examples: https://slider.react-component.now.sh/

Usage

Slider

import Slider from 'rc-slider';
import 'rc-slider/assets/index.css';

export default () => (
  <>
    <Slider />
  </>
);

Range

Please refer to #825 for information regarding usage of Range. An example:

import Slider, { Range } from 'rc-slider';
import 'rc-slider/assets/index.css';

export default () => (
  <>
    <Slider range />
  </>
);

Compatibility

IE / Edge
IE / Edge
Firefox
Firefox
Chrome
Chrome
Safari
Safari
Electron
Electron
IE11, Edge last 2 versions last 2 versions last 2 versions last 2 versions

API

createSliderWithTooltip(Slider | Range) => React.Component

An extension to make Slider or Range support Tooltip on handle.

const Slider = require('rc-slider');
const createSliderWithTooltip = Slider.createSliderWithTooltip;
const Range = createSliderWithTooltip(Slider.Range);

Online demo

After Range or Slider was wrapped by createSliderWithTooltip, it will have the following props:

Name Type Default Description
tipFormatter (value: number): React.ReactNode value => value A function to format tooltip's overlay
tipProps Object {
placement: 'top',
prefixCls: 'rc-slider-tooltip',
overlay: tipFormatter(value)
}
A function to format tooltip's overlay

Common API

The following APIs are shared by Slider and Range.

Name Type Default Description
className string '' Additional CSS class for the root DOM node
min number 0 The minimum value of the slider
max number 100 The maximum value of the slider
marks {number: ReactNode} or{number: { style, label }} {} Marks on the slider. The key determines the position, and the value determines what will show. If you want to set the style of a specific mark point, the value should be an object which contains style and label properties.
step number or null 1 Value to be added or subtracted on each step the slider makes. Must be greater than zero, and max - min should be evenly divisible by the step value.
When marks is not an empty object, step can be set to null, to make marks as steps.
vertical boolean false If vertical is true, the slider will be vertical.
handle (props) => React.ReactNode A handle generator which could be used to customized handle.
included boolean true If the value is true, it means a continuous value interval, otherwise, it is a independent value.
reverse boolean false If the value is true, it means the component is rendered reverse.
disabled boolean false If true, handles can't be moved.
keyboard boolean true Support using keyboard to move handlers.
dots boolean false When the step value is greater than 1, you can set the dots to true if you want to render the slider with dots.
onBeforeChange Function NOOP onBeforeChange will be triggered when ontouchstart or onmousedown is triggered.
onChange Function NOOP onChange will be triggered while the value of Slider changing.
onAfterChange Function NOOP onAfterChange will be triggered when ontouchend or onmouseup is triggered.
minimumTrackStyle Object please use trackStyle instead. (only used for slider, just for compatibility , will be deprecate at [email protected] )
maximumTrackStyle Object please use railStyle instead (only used for slider, just for compatibility , will be deprecate at [email protected])
handleStyle Array[Object] | Object [{}] The style used for handle. (both for slider(Object) and range(Array of Object), the array will be used for multi handle following element order)
trackStyle Array[Object] | Object [{}] The style used for track. (both for slider(Object) and range(Array of Object), the array will be used for multi track following element order)
railStyle Object {} The style used for the track base color.
dotStyle Object | (dotValue) => Object {} The style used for the dots.
activeDotStyle Object | (dotValue) => Object {} The style used for the active dots.

Slider

Name Type Default Description
defaultValue number 0 Set initial value of slider.
value number - Set current value of slider.
startPoint number undefined Track starts from this value. If undefined, min is used.
tabIndex number 0 Set the tabIndex of the slider handle.
ariaLabelForHandle string - Set the aria-label attribute on the slider handle.
ariaLabelledByForHandle string - Set the aria-labelledby attribute on the slider handle.
ariaValueTextFormatterForHandle (value) => string - A function to set the aria-valuetext attribute on the slider handle. It receives the current value of the slider and returns a formatted string describing the value. See WAI-ARIA Authoring Practices 1.1 for more information.

Range

Name Type Default Description
defaultValue number[] [0, 0] Set initial positions of handles.
value number[] Set current positions of handles.
tabIndex number[] [0, 0] Set the tabIndex of each handle.
ariaLabelGroupForHandles Array[string] - Set the aria-label attribute on each handle.
ariaLabelledByGroupForHandles Array[string] - Set the aria-labelledby attribute on each handle.
ariaValueTextFormatterGroupForHandles Array[(value) => string] - A function to set the aria-valuetext attribute on each handle. It receives the current value of the slider and returns a formatted string describing the value. See WAI-ARIA Authoring Practices 1.1 for more information.
count number 1 Determine how many ranges to render, and multiple handles will be rendered (number + 1).
allowCross boolean true allowCross could be set as true to allow those handles to cross.
pushable boolean or number false pushable could be set as true to allow pushing of surrounding handles when moving a handle. When set to a number, the number will be the minimum ensured distance between handles. Example:
draggableTrack boolean false Open the track drag. open after click on the track will be invalid.

SliderTooltip

The Tooltip Component that keep following with content.

Development

npm install
npm start

Test Case

npm run test

Coverage

npm run coverage

License

rc-slider is released under the MIT license.

More Repositories

1

form

React High Order Form Component(web & react-native)
JavaScript
1,799
star
2

calendar

React Calendar
JavaScript
1,681
star
3

table

React Table
TypeScript
1,183
star
4

tree

React Tree
TypeScript
1,113
star
5

field-form

⚡️ React Performance First Form Component
TypeScript
914
star
6

tooltip

React Tooltip
TypeScript
896
star
7

select

React Select
TypeScript
854
star
8

upload

React Upload
TypeScript
766
star
9

progress

React Progress Bar
TypeScript
678
star
10

animate

anim react element easily
JavaScript
675
star
11

menu

React Menu
TypeScript
655
star
12

virtual-list

🧾 React Virtual List Component which worked with animation
TypeScript
645
star
13

pagination

React Pagination
TypeScript
629
star
14

util

Common Utils For React Component
TypeScript
627
star
15

tabs

React Tabs
TypeScript
540
star
16

queue-anim

Animate React Component in queue
TypeScript
476
star
17

time-picker

React TimePicker
JavaScript
463
star
18

dialog

React Dialog
TypeScript
424
star
19

color-picker

React ColorPicker
TypeScript
422
star
20

m-date-picker

React Mobile DatePicker(web & react-native)
TypeScript
400
star
21

react-component.github.io

docs and site of react-component
HTML
378
star
22

drawer

React Drawer
TypeScript
372
star
23

tween-one

Animate One React Element
TypeScript
370
star
24

notification

React Notification
TypeScript
364
star
25

trigger

Abstract React Trigger
TypeScript
345
star
26

collapse

React Collapse / Accordion
TypeScript
319
star
27

steps

React Steps
TypeScript
311
star
28

scroll-anim

Animate Scroll React Component
JavaScript
301
star
29

input-number

React Input Number
TypeScript
296
star
30

tree-select

React Tree Select
TypeScript
287
star
31

picker

📅 All Date Pickers you need.
TypeScript
265
star
32

m-picker

React Mobile Picker(web & react-native)
TypeScript
247
star
33

swipeout

React Swipeout(web & react-native)
TypeScript
213
star
34

rc-tools

Tools For React Component
JavaScript
205
star
35

cascader

cascade select in one box
TypeScript
198
star
36

switch

React Switch
JavaScript
187
star
37

image

🖼 React Image Component
TypeScript
185
star
38

banner-anim

Animate Banner React Component
JavaScript
170
star
39

m-pull-to-refresh

React Mobile Pull To Refresh
TypeScript
164
star
40

dropdown

React Dropdown
TypeScript
163
star
41

texty

React Text Animate
TypeScript
154
star
42

resize-observer

👓 Resize observer for React
JavaScript
153
star
43

m-tabs

React Mobile Tabs Component (web & react-native)
TypeScript
139
star
44

checkbox

React Checkbox
TypeScript
130
star
45

motion

⛷ CSS Animation for React
TypeScript
120
star
46

gesture

Support gesture for react component.
TypeScript
103
star
47

rate

React Rate
JavaScript
91
star
48

footer

🐾 Pretty Footer react component used in ant.design
JavaScript
87
star
49

form-validation

This project is deprecated, you can try https://github.com/react-component/form
JavaScript
86
star
50

m-list-view

ReactNative ListView Web Port
JavaScript
85
star
51

align

Abstract React Align
TypeScript
81
star
52

mentions

React Mentions
TypeScript
67
star
53

rn-packager

Standalone ReactNative Packager
JavaScript
66
star
54

generator-rc

yeoman generator for react component
JavaScript
58
star
55

editor-core

a draft-js based editor
TypeScript
56
star
56

m-drawer

React Drawer
JavaScript
54
star
57

cropping

image cropping
TypeScript
54
star
58

editor-mention

React Mention
JavaScript
53
star
59

m-cascader

React Mobile Cascader Component(web and react-native)
TypeScript
51
star
60

m-dialog

React Mobile Dialog(web & react-native)
TypeScript
45
star
61

spider

React Tree Diagrams
JavaScript
44
star
62

overflow

📦 Auto collapse box util component
TypeScript
42
star
63

css-transition-group

standalone CSSTransitionGroup for React.addons.CSSTransitionGroup
JavaScript
38
star
64

m-calendar

React Mobile Calendar Component (web)
TypeScript
36
star
65

m-feedback

:active pseudo-class with react for mobile
TypeScript
36
star
66

input

React Input Component
TypeScript
35
star
67

tour

TypeScript
30
star
68

pager

React Pager
JavaScript
26
star
69

m-notification

JavaScript
23
star
70

dropzone

React Dropzone
JavaScript
23
star
71

textarea

React Textarea
TypeScript
22
star
72

radio

[DEPRECATED] React Radio
CSS
19
star
73

m-input-number

input-number mobile ui component for react (web & react-native)
TypeScript
17
star
74

portal

TypeScript
16
star
75

touchable

React Touchable Component
TypeScript
16
star
76

rc-server

This project is deprecated, use rc-tools run server
JavaScript
15
star
77

gulp-jsx2example

Compile JSX file to HTML (react demo)
JavaScript
13
star
78

cascade-select

React CascadeSelect
JavaScript
13
star
79

icon-anim

Icon cutover or morph animate React Element
JavaScript
12
star
80

m-select-list

React Mobile Select List Component
JavaScript
12
star
81

segmented

React Segmented Controls
TypeScript
12
star
82

rc-test

test react component
JavaScript
11
star
83

mobile

ant design mobile components
TypeScript
10
star
84

m-tooltip

React Tooltip for mobile
TypeScript
8
star
85

context

TypeScript
7
star
86

rn-tools

tools for react-native
JavaScript
7
star
87

rn-core

Standalone ReactNative Framework
Objective-C
6
star
88

m-trigger

React Trigger Component for mobile
JavaScript
6
star
89

record

Record audio from microphone
JavaScript
5
star
90

.github

5
star
91

RNPlayground

react-native playground container
Objective-C
5
star
92

mutate-observer

TypeScript
5
star
93

editor-plugin-emoji

HTML
4
star
94

m-steps

React Steps for mobile
CSS
4
star
95

editor-plugin-basic-style

TypeScript
3
star
96

mini-decimal

TypeScript
3
star
97

editor-utils

editor utilities
TypeScript
2
star
98

father-plugin

father plugin for all react-component project
TypeScript
1
star
99

qrcode

TypeScript
1
star
100

editor-plugin-image

TypeScript
1
star