11.1.7 • Published 2 months ago

rc-slider v11.1.7

Weekly downloads
908,942
License
MIT
Repository
github
Last release
2 months ago

rc-slider

Slider UI component for React

NPM version npm download build status Codecov bundle size dumi

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 / EdgeFirefoxChromeSafariElectron
IE11, Edgelast 2 versionslast 2 versionslast 2 versionslast 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:

NameTypeDefaultDescription
tipFormatter(value: number): React.ReactNodevalue => valueA function to format tooltip's overlay
tipPropsObject{ 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.

NameTypeDefaultDescription
classNamestring''Additional CSS class for the root DOM node
minnumber0The minimum value of the slider
maxnumber100The maximum value of the slider
idstring''Unique identifier for the component, used for accessibility
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.
stepnumber or null1Value 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.
verticalbooleanfalseIf vertical is true, the slider will be vertical.
handle(props) => React.ReactNodeA handle generator which could be used to customized handle.
includedbooleantrueIf the value is true, it means a continuous value interval, otherwise, it is a independent value.
reversebooleanfalseIf the value is true, it means the component is rendered reverse.
disabledbooleanfalseIf true, handles can't be moved.
keyboardbooleantrueSupport using keyboard to move handlers.
dotsbooleanfalseWhen the step value is greater than 1, you can set the dots to true if you want to render the slider with dots.
onBeforeChangeFunctionNOOPonBeforeChange will be triggered when ontouchstart or onmousedown is triggered.
onChangeFunctionNOOPonChange will be triggered while the value of Slider changing.
onChangeCompleteFunctionNOOPonChangeComplete will be triggered when ontouchend or onmouseup is triggered.
minimumTrackStyleObjectplease use trackStyle instead. (only used for slider, just for compatibility , will be deprecate at rc-slider@9.x)
maximumTrackStyleObjectplease use railStyle instead (only used for slider, just for compatibility , will be deprecate at rc-slider@9.x)
handleStyleArrayObject | 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)
trackStyleArrayObject | 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)
railStyleObject{}The style used for the track base color.
dotStyleObject | (dotValue) => Object{}The style used for the dots.
activeDotStyleObject | (dotValue) => Object{}The style used for the active dots.

Slider

NameTypeDefaultDescription
defaultValuenumber0Set initial value of slider.
valuenumber-Set current value of slider.
startPointnumberundefinedTrack starts from this value. If undefined, min is used.
tabIndexnumber0Set the tabIndex of the slider handle.
ariaLabelForHandlestring-Set the aria-label attribute on the slider handle.
ariaLabelledByForHandlestring-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

NameTypeDefaultDescription
defaultValuenumber[][0, 0]Set initial positions of handles.
valuenumber[]Set current positions of handles.
tabIndexnumber[][0, 0]Set the tabIndex of each handle.
ariaLabelGroupForHandlesArraystring-Set the aria-label attribute on each handle.
ariaLabelledByGroupForHandlesArraystring-Set the aria-labelledby attribute on each handle.
ariaValueTextFormatterGroupForHandlesArray(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.
countnumber1Determine how many ranges to render, and multiple handles will be rendered (number + 1).
allowCrossbooleantrueallowCross could be set as true to allow those handles to cross.
pushableboolean or numberfalsepushable 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: npm.io
draggableTrackbooleanfalseOpen 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.

11.1.6

2 months ago

11.1.7

2 months ago

11.0.6

4 months ago

11.0.5

4 months ago

11.0.2

4 months ago

11.0.0

4 months ago

11.0.1

4 months ago

11.1.5

4 months ago

11.1.3

4 months ago

11.1.1

4 months ago

11.1.2

4 months ago

11.1.0

4 months ago

10.6.2

7 months ago

10.6.0

7 months ago

10.6.1

7 months ago

10.6.0-4

7 months ago

10.6.0-1

7 months ago

10.6.0-0

7 months ago

10.6.0-3

7 months ago

10.4.1

12 months ago

10.4.0

1 year ago

10.3.1

1 year ago

10.5.0

12 months ago

10.3.0

1 year ago

10.2.0

1 year ago

10.2.1

1 year ago

10.1.1

2 years ago

10.1.0

2 years ago

10.0.1

2 years ago

10.0.0

3 years ago

10.0.0-alpha.6

3 years ago

10.0.0-alpha.5

3 years ago

10.0.0-alpha.4

3 years ago

10.0.0-alpha.3

3 years ago

10.0.0-alpha.2

3 years ago

10.0.0-alpha.1

3 years ago

10.0.0-alpha.0

3 years ago

9.7.5

3 years ago

9.7.4

3 years ago

9.7.2

4 years ago

9.7.1

4 years ago

9.6.5

4 years ago

9.6.4

4 years ago

9.6.3

4 years ago

9.6.2

4 years ago

9.6.1

4 years ago

9.6.0

4 years ago

9.5.4

4 years ago

9.5.3

4 years ago

9.5.2

4 years ago

9.5.1

4 years ago

9.5.0

4 years ago

9.4.1

4 years ago

9.4.0

4 years ago

9.3.1

4 years ago

9.3.0

4 years ago

9.2.4

5 years ago

9.2.3

5 years ago

9.2.2

5 years ago

9.2.1

5 years ago

9.2.0

5 years ago

9.1.1

5 years ago

9.1.0

5 years ago

9.0.0-alpha.0

5 years ago

8.7.1

5 years ago

8.7.0

5 years ago

8.6.13

5 years ago

8.6.12

5 years ago

8.6.11

6 years ago

8.6.10

6 years ago

8.6.9

6 years ago

8.6.8

6 years ago

8.6.7

6 years ago

8.6.6

6 years ago

8.6.5

6 years ago

8.6.4

6 years ago

8.6.3

6 years ago

8.6.2

6 years ago

8.6.1

7 years ago

8.6.0

7 years ago

8.5.0

7 years ago

8.4.1

7 years ago

8.4.0

7 years ago

8.3.5

7 years ago

8.3.4

7 years ago

8.3.3

7 years ago

8.3.2

7 years ago

8.3.1

7 years ago

8.3.0

7 years ago

8.2.0

7 years ago

8.1.5

7 years ago

8.1.4

7 years ago

8.1.3

7 years ago

8.1.2

7 years ago

8.1.1

7 years ago

8.1.0

7 years ago

8.0.2

7 years ago

8.0.1

7 years ago

8.0.0

7 years ago

7.0.8

8 years ago

7.0.7

8 years ago

7.0.6

8 years ago

7.0.5

8 years ago

7.0.4

8 years ago

7.0.3

8 years ago

7.0.2

8 years ago

7.0.1

8 years ago

7.0.0

8 years ago

6.3.1

8 years ago

6.3.0

8 years ago

6.2.0

8 years ago

6.1.2

8 years ago

6.1.1

8 years ago

6.1.0

8 years ago

6.0.2

8 years ago

6.0.1

8 years ago

6.0.0

8 years ago

5.4.3

8 years ago

5.4.2

8 years ago

5.4.1

8 years ago

5.4.0

8 years ago

5.3.5

8 years ago

5.3.4

8 years ago

5.3.3

8 years ago

5.3.2

8 years ago

5.3.1

8 years ago

5.3.0

8 years ago

5.2.1

8 years ago

5.2.0

8 years ago

5.1.3

8 years ago

5.1.2

8 years ago

5.1.1

8 years ago

5.1.0

8 years ago

5.0.0

8 years ago

4.0.1

8 years ago

4.0.0

8 years ago

3.8.2

8 years ago

3.8.1

8 years ago

3.8.0

8 years ago

3.7.4

8 years ago

3.7.3

8 years ago

3.7.2

8 years ago

3.7.1

8 years ago

3.7.0

8 years ago

3.6.2

9 years ago

3.6.0

9 years ago

3.5.1

9 years ago

3.5.0

9 years ago

3.4.0

9 years ago

3.3.2

9 years ago

3.3.1

9 years ago

3.3.0

9 years ago

3.1.6

9 years ago

3.1.5

9 years ago

3.2.0

9 years ago

3.1.4

9 years ago

3.1.3

9 years ago

3.1.2

9 years ago

3.1.1

9 years ago

3.1.0

9 years ago

3.0.1

9 years ago

3.0.0

9 years ago

2.3.2

9 years ago

2.3.1

9 years ago

2.2.1

9 years ago

2.2.0

9 years ago

2.1.0

9 years ago

2.0.1

9 years ago

2.0.0

9 years ago

1.6.0

9 years ago

1.5.2

9 years ago

1.5.1

9 years ago

1.5.0

9 years ago

1.4.5

9 years ago

1.4.4

9 years ago

1.4.3

9 years ago

1.4.2

9 years ago

1.4.1

9 years ago

1.4.0

9 years ago

1.3.1

9 years ago

1.3.0

9 years ago

1.2.10

9 years ago

1.2.9

9 years ago

1.2.8

9 years ago

1.2.7

9 years ago

1.2.6

9 years ago

1.2.5

9 years ago

1.2.4

9 years ago

1.2.3

9 years ago

1.2.2

9 years ago

1.2.1

9 years ago

1.2.0

9 years ago

1.1.1

9 years ago

1.1.0

10 years ago

1.0.0

10 years ago