react-toolbox/components/slider
rubenmoya 6fa13f1c5c Use proper code values in KEYS constant 🤦🏻‍♂️ 2018-03-03 12:01:46 +01:00
..
__tests__ Merge branch 'dev' into fix-key-events-slider-disabled 2018-03-03 11:59:42 +01:00
Slider.d.ts feat(slider): add buffer prop to Slider (#1317) 2017-04-02 14:16:09 +02:00
Slider.js Use proper code values in KEYS constant 🤦🏻‍♂️ 2018-03-03 12:01:46 +01:00
config.css Migrate styles to PostCSS (#666) 2017-01-05 02:42:18 +01:00
index.d.ts Restructure typescript definitions (#1114) 2017-01-18 08:37:37 +01:00
index.js Update dependencies and linter (#1180) 2017-01-26 18:05:32 +01:00
readme.md Add callback functions to slider for when slider starts being dragged, and when it stops. (#1287) 2017-04-02 14:09:11 +02:00
theme.css Fixes #1127 2017-01-18 10:56:03 +01:00

readme.md

Slider

Sliders let users select a value from a continuous or discrete range of values by moving the slider thumb. The smallest value is to the left, the largest to the right. Sliders can have icons to the left and right of the bar that reflect the value intensity. The interactive nature of the slider makes it a great choice for settings that reflect intensity levels, such as volume, brightness, or color saturation.

import Slider from 'react-toolbox/lib/slider';

class SliderTest extends React.Component {
  state = {
    slider2: 5,
    slider3: 1,
    slider4: 3
  };

  handleChange = (slider, value) => {
    const newState = {};
    newState[slider] = value;
    this.setState(newState);
  };

  render () {
    return (
      <section>
        <p>Normal slider</p>
        <Slider value={this.state.slider1} onChange={this.handleChange.bind(this, 'slider1')} />
        <p>With steps, initial value and editable</p>
        <Slider min={0} max={10} editable value={this.state.slider2} onChange={this.handleChange.bind(this, 'slider2')} />
        <p>Pinned and with snaps</p>
        <Slider pinned snaps min={0} max={10} step={1} editable value={this.state.slider3} onChange={this.handleChange.bind(this, 'slider3')} />
        <p>Disabled</p>
        <Slider disabled min={0} max={10} value={this.state.slider4} onChange={this.handleChange.bind(this, 'slider4')} />
      </section>
    );
  }
}

This component can be styled by context providing a theme with the key RTSlider through the theme provider.

Properties

Name Type Default Description
className String '' Additional class name to provide custom styling.
disabled Boolean false If true, component will be disabled.
editable Boolean false If true, an input is shown and the user can set the slider from keyboard value.
max Number 100 Maximum value permitted.
min Number 0 Minimum value permitted.
onChange Function Callback function that will be invoked when the slider value changes.
onDragStart Function () => {} Callback function that will be invoked when the slider starts being dragged.
onDragStop Function () => {} Callback function that will be invoked when the slider stops being dragged.
pinned Boolean false If true, a pin with numeric value label is shown when the slider thumb is pressed. Use for settings for which users need to know the exact value of the setting.
snaps Boolean false If true, the slider thumb snaps to tick marks evenly spaced based on the step property value.
step Number 0.01 Amount to vary the value when the knob is moved or increase/decrease is called.
value Number 0 Current value of the slider.

Theme

Name Description
container Used as an inner container of the root component.
editable Added to the root of in case the Slider is editable.
innerknob Used to style the inner element of the knob.
innerprogress Provided to the ProgressBar component.
input Provided to the Input element in case it's editable.
knob Used to style the outer layer of the knob.
pinned Added to the root in case the Slider is pinned.
pressed Added to the root in case the state is pressed.
progress Used as an outer wrapper for the ProgressBar.
ring Used in the root when the knob should be a ring.
slider Class used for the root element.
snap Used for every individual snap element.
snaps Used as a wrapper for the group of snaps when it's snapped.