mirror of
https://github.com/zhigang1992/react-native-slider.git
synced 2026-04-27 21:07:56 +08:00
52bad73244d1b042c9be2bfc0d7180f51ebac3eb
react-native-slider
A pure JavaScript <Slider> component for react-native. This is still very much a work
in progress, ideas and contributions are very welcome.
Install
npm i --save react-native-slider
Usage
'use strict';
var React = require('react-native');
var Slider = require('react-native-slider');
var {
AppRegistry,
StyleSheet,
View,
Text,
} = React;
var SliderExample = React.createClass({
getInitialState() {
return {
value: 0.2,
};
},
render() {
return (
<View style={styles.container}>
<Slider
value={this.state.value}
onValueChange={(value) => this.setState({value})} />
<Text>Value: {this.state.value}</Text>
</View>
);
}
});
var styles = StyleSheet.create({
container: {
flex: 1,
marginLeft: 10,
marginRight: 10,
alignItems: 'stretch',
justifyContent: 'center',
},
});
AppRegistry.registerComponent('SliderExample', () => SliderExample);
Props
| Prop | Type | Optional | Default | Description |
|---|---|---|---|---|
| value | number | Yes | 0 | Initial value of the slider |
| minimumValue | number | Yes | 0 | Initial minimum value of the slider |
| maximumValue | number | Yes | 1 | Initial maximum value of the slider |
| minimumTrackTintColor | string | Yes | '#3f3f3f' | The color used for the track to the left of the button |
| maximumTrackTintColor | string | Yes | '#b3b3b3' | The color used for the track to the right of the button |
| thumbTintColor | string | Yes | '#343434' | The color used for the thumb |
| onValueChange | function | Yes | Callback continuously called while the user is dragging the slider | |
| onSlidingComplete | function | Yes | Callback called when the user finishes changing the value (e.g. when the slider is released) |
MIT Licensed
Languages
JavaScript
74%
Objective-C
16.6%
Starlark
5%
Java
4.4%
