1.0.9 • Published 4 years ago

react-custom-slider v1.0.9

Weekly downloads
24
License
MIT
Repository
github
Last release
4 years ago

react-custom-slider

a very easy to use customizable slider for React

  • easy to use
  • no dependencies
  • flexible (few required parameters but highly customizable)

NPM JavaScript Style Guide

sliders

Install

npm install --save react-custom-slider

Usage

import React from 'react'

import Slider from 'react-custom-slider';

const App = () => {
  const [ value, setValue ] = React.useState(0);

  return(
    <div>
      <Slider
        value={value}
        markersSize={20}
        trackLength={250}
        markers={11}
        onChange={(value) => setValue(value)}
        valueRenderer={(value) => `${value}%`}
      />
    </div>
  )
};

export default App;

Props

PropTypeDescription
valuenumber (required)continuously updated value
defaultValuenumber (required)initial value
showValuetrue, false, 'active'displays current value on a label
valueLabelColorstring
valueLabelActiveColorstring
valueLabelPaddingnumber
valueLabelStyleobjectuser custom style for value label
minnumbermin slider value
maxnumbermax slider value
stepSizenumberinterval between 2 steps (default is 1)
disabledboolean
disabledColorstringcolor used when the slider is disabled
onChangefunction (callback)called every time value changes ( value as argument)
onReleasefunction (callback)called once slider is released ( value as argument)
valueRendererfunction (callback)used by value label (to display a unit such as %)
trackLengthnumbertrack's height or width (depending on the orientation)
trackColorstring
trackThicknessnumber
trackShape'squared', 'rounded'
trackStyleobjectuser custom styling for track
fillTrackboolean
fillColorstring
handlerSizenumbersets handler diameter (both width and height)
handlerWidthnumber
handlerHeightnumber
handlerShape'squared', 'rounded'
handlerColorstring
handlerBorderColor
handlerActiveColorstringhandler color when slider is being used
handlerStyleobjectuser custom styling for handler
fontSizenumberused by markers
fontColorstringused by markers
markersnumbernumbers of markers to display
markersSizenumbermarkers container's height or width (depending on the orientation)
showMarkerstrue, false, 'hidden', 'active', 'inactive''active' displays the markers only when slider is beeing used, 'inactive' the opposite
grabCursorbooleanwhen true shows a grabbing cursor as slider is beeing used
verticalbooleanslider's layout horizontal or vertical
invertMarkersbooleanswitch slider and markers positions
styleobjectuser custom style for slider's root container

License

MIT © jonisapp

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago