Note: SliderIOS is deprecated and will be removed in the future. Use the cross-platform Slider as a drop-in replacement with the same API.

An iOS-specific component used to select a single value from a range of values.

Props

View props...

disabled bool

If true the user won't be able to move the slider. Default value is false.

maximumTrackImage Image.propTypes.source

Assigns a maximum track image. Only static images are supported. The leftmost pixel of the image will be stretched to fill the track.

maximumTrackTintColor string

The color used for the track to the right of the button. Overrides the default blue gradient image.

maximumValue number

Initial maximum value of the slider. Default value is 1.

minimumTrackImage Image.propTypes.source

Assigns a minimum track image. Only static images are supported. The rightmost pixel of the image will be stretched to fill the track.

minimumTrackTintColor string

The color used for the track to the left of the button. Overrides the default blue gradient image.

minimumValue number

Initial minimum value of the slider. Default value is 0.

onSlidingComplete function

Callback called when the user finishes changing the value (e.g. when the slider is released).

onValueChange function

Callback continuously called while the user is dragging the slider.

step number

Step value of the slider. The value should be between 0 and (maximumValue - minimumValue). Default value is 0.

style View#style

Used to style and layout the Slider. See StyleSheet.js and ViewStylePropTypes.js for more info.

thumbImage Image.propTypes.source

Sets an image for the thumb. It only supports static images.

trackImage Image.propTypes.source

Assigns a single image for the track. Only static images are supported. The center pixel of the image will be stretched to fill the track.

value number

Initial value of the slider. The value should be between minimumValue and maximumValue, which default to 0 and 1 respectively. Default value is 0.

This is not a controlled component, e.g. if you don't update the value, the component won't be reset to its initial value.

Examples

'use strict';

var React = require('react');
var ReactNative = require('react-native');
var {
  SliderIOS,
  Text,
  StyleSheet,
  View,
} = ReactNative;

var SliderExample = React.createClass({
  getInitialState() {
    return {
      value: 0,
    };
  },

  render() {
    return (
      <View>
        <Text style={styles.text} >
          {this.state.value}
        </Text>
        <SliderIOS
          {...this.props}
          onValueChange={(value) => this.setState({value: value})} />
      </View>
    );
  }
});

var styles = StyleSheet.create({
  slider: {
    height: 10,
    margin: 10,
  },
  text: {
    fontSize: 14,
    textAlign: 'center',
    fontWeight: '500',
    margin: 10,
  },
});

exports.title = '<SliderIOS>';
exports.displayName = 'SliderExample';
exports.description = 'Slider input for numeric values';
exports.examples = [
  {
    title: 'Default settings',
    render(): ReactElement<any> {
      return <SliderExample />;
    }
  },
  {
    title: 'minimumValue: -1, maximumValue: 2',
    render(): ReactElement<any> {
      return (
        <SliderExample
          minimumValue={-1}
          maximumValue={2}
        />
      );
    }
  },
  {
    title: 'step: 0.25',
    render(): ReactElement<any> {
      return <SliderExample step={0.25} />;
    }
  },
  {
    title: 'Custom min/max track tint color',
    render(): ReactElement<any> {
      return (
        <SliderExample
          minimumTrackTintColor={'red'}
          maximumTrackTintColor={'green'}
        />
      );
    }
  },
  {
    title: 'Custom thumb image',
    render(): ReactElement<any> {
      return <SliderExample thumbImage={require('./uie_thumb_big.png')} />;
    }
  },
  {
    title: 'Custom track image',
    render(): ReactElement<any> {
      return <SliderExample trackImage={require('./slider.png')} />;
    }
  },
  {
    title: 'Custom min/max track image',
    render(): ReactElement<any> {
      return (
        <SliderExample
          minimumTrackImage={require('./slider-left.png')}
          maximumTrackImage={require('./slider-right.png')}
        />
      );
    }
  },
];
SliderIOS#minimumValue

minimumValue number Initial minimum value of the slider. Default value is 0.

2016-06-23 04:25:23
SliderIOS#maximumValue

maximumValue number Initial maximum value of the slider. Default value is 1.

2016-06-23 04:25:22
SliderIOS#minimumTrackTintColor

minimumTrackTintColor string The color used for the track to the left of the button. Overrides the default

2016-06-23 04:25:23
SliderIOS#thumbImage

thumbImage Image.propTypes.source Sets an image for the thumb. It only supports static images.

2016-06-23 04:25:24
SliderIOS#value

value number Initial value of the slider. The value should be between minimumValue and maximumValue, which

2016-06-23 04:25:24
SliderIOS#onSlidingComplete

onSlidingComplete function Callback called when the user finishes changing the value (e.g. when the slider

2016-06-23 04:25:23
SliderIOS#minimumTrackImage

minimumTrackImage Image.propTypes.source Assigns a minimum track image. Only static images are supported

2016-06-23 04:25:22
SliderIOS#maximumTrackTintColor

maximumTrackTintColor string The color used for the track to the right of the button. Overrides the default

2016-06-23 04:25:22
SliderIOS#onValueChange

onValueChange function Callback continuously called while the user is dragging the slider.

2016-06-23 04:25:23
SliderIOS#trackImage

trackImage Image.propTypes.source Assigns a single image for the track. Only static images are supported

2016-06-23 04:25:24