Carousel component for react-native
Installation
npm install react-native-carousel
Properties
hideIndicators={false}
indicatorColor="#FFFFFF"
indicatorSize={20}
indicatorSpace={15}
inactiveIndicatorColor="#999999"
indicatorAtBottom={true}
indicatorOffset={250}
onPageChange={callback}
inactiveIndicatorText= '•'
indicatorText= '•'
animate={true}
delay={1000}
loop={true}
Usage example
Assuming you have npm install -g react-native-cli
, first generate an app:
react-native init RNCarousel
cd RNCarousel
npm install react-native-carousel --save
Then paste the following into RNCarousel/index.ios.js
:
'use strict';
var React = require('react-native');
var {
AppRegistry,
StyleSheet,
Text,
View,
} = React;
var Carousel = require('react-native-carousel');
var RNCarousel = React.createClass({
render: function() {
return (
<Carousel width={375}>
<View style={styles.container}>
<Text>Page 1</Text>
</View>
<View style={styles.container}>
<Text>Page 2</Text>
</View>
<View style={styles.container}>
<Text>Page 3</Text>
</View>
</Carousel>
);
}
});
var styles = StyleSheet.create({
container: {
width: 375,
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: 'transparent',
},
});
AppRegistry.registerComponent('RNCarousel', () => RNCarousel);