You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
React Native component designed to display the current page of a swiper, slideshow, carousel, and more. You can choose from three pre-defined design variants and further customize the look and feel according to your specific requirements. All design variants support both horizontal and vertical orientations. This package has no dependencies and utilizes React Native's Animated API with the native driver to achieve seamless and fluid animations.
Horizontal
Vertical
Design Variants
Morse
Beads
Train
Installation
yarn add react-native-page-indicator
# or
npm install react-native-page-indicator
Basic example
Pass the total number of pages as the count prop and the current page index as the current prop.
importReactfrom'react';import{View,StyleSheet}from'react-native';import{PageIndicator}from'react-native-page-indicator';constMyComponent=({ pages, current })=>(<Viewstyle={styles.wrapper}><PageIndicatorcount={pages}current={current}/></View>);conststyles=StyleSheet.create({wrapper: {flex: 1,alignItems: 'center',justifyContent: 'center',},});exportdefaultMyComponent;
Advanced example
To create a more engaging experience where the indicator dynamically responds to the scroll position, you can pass the current page index as an Animated.Value rather than a regular number. The easiest approach to obtain the animated value is by dividing the corresponding scroll position by the page width (for horizontal scrolling) or page height (for vertical scrolling).