React Native Image Slider Box Example

Jul 07, 2022 . Admin

Hi Guys,

Now, let's see example of react native image slider box example. This tutorial will give you simple example of how to implement image slider box in react native. In this article, we will implement a how to use image slider box in react native. if you want to see example of image slider box example in react native then you are a right place. So, let's follow few step to create example of how to add image slider box in react native.

Let's start following example:

Step 1: Download Project

In the first step run the following command to create a project.

expo init ExampleApp
Step 2: Install and Setup

First of all you have to install react-native-image-slider package.

npm install react-native-image-slider-box --save
Step 3: App.js

In this step, You will open the App.js file and put the code.

import React from 'react';
import { StatusBar, StyleSheet, View } from 'react-native';
import { SliderBox } from 'react-native-image-slider-box';

const App = () => {
    const [images, setImages] = React.useState([
        "https://source.unsplash.com/1024x768/?nature",
        "https://source.unsplash.com/1024x768/?water",
        "https://source.unsplash.com/1024x768/?tree",
    ]);

    return (
        <View style={styles.container}>
            <SliderBox 
                images={images}
                sliderBoxHeight={400}
                dotColor="#FFEE58"
                inactiveDotColor="#90A4AE"  
                onCurrentImagePressed={index => console.warn(`image ${index} pressed`)}
                paginationBoxVerticalPadding={20}
                autoplay
                circleLoop
            />
            <StatusBar />
        </View>
    );
}

const styles = StyleSheet.create({
    container: {
        backgroundColor: 'white',
        paddingTop: 10,
        flex: 1,
    },
});

export default App;
Run Project

In the last step run your project using the below command.

expo start

You can QR code scan in Expo Go Application on mobile.

Output :

It will help you...

#React Native