Skip to main content

Carousel carousel component

Effect demonstration

1. Default configuration

<Carousel>
<Image source={require("../../assets/images/img-01.jpg")} />
<Image source={require("../../assets/images/img-02.jpg")} />
<Image source={require("../../assets/images/img-03.jpeg")} />
</Carousel>
Carousel-ios1.gif

2. width 200, height 100

<Carousel width={px(200)} height={px(100)}>
<Image source={require("../../assets/images/img-01.jpg")} />
<Image source={require("../../assets/images/img-02.jpg")} />
<Image source={require("../../assets/images/img-03.jpeg")} />
</Carousel>
Carousel-ios2.gif
<Carousel duration={1000}>
<Image source={require("../../assets/images/img-01.jpg")} />
<Image source={require("../../assets/images/img-02.jpg")} />
<Image source={require("../../assets/images/img-03.jpeg")} />
</Carousel>
Carousel-ios5.gif

4. Modify indicator color

 <Carousel duration={1000} activeColor="red" inactiveColor="grey">
<Image source={require('../../../assets/images/img-01.png')} />
<Image source={require('../../../assets/images/img-02.png')} />
<Image source={require('../../../assets/images/img-03.png')} />
</Carousel>
Carousel-ios8.gif

API

PropertiesRequiredDescriptionTypeDefault Value
autofalseWhether to scroll automaticallybooleantrue
widthfalseCarousel widthnumberdeviceWidth
heightfalseCarousel heightnumber320
durationfalseCarousel duration (milliseconds)number2000
indicatorEnabledfalseWhether to display the scroll indicatorbooleantrue
indicatorSizefalseindicator sizenumber10
activeColorfalseColor when the origin is selectedstring#fff
inactiveColorfalseColor when origin is not selectedstring#fff
alignfalseIndicator layout.AlignTypecenter

The types of AlignType are as follows:

type AlignType = "left" | "center" | "right";