Skip to main content

ProgressStepperVertical

ProgressStepperVertical in itself gets all the necessary details from ProgressStepperVerticalProvider. This helps to avoid passing same props to each screen.

In terms of single page usage, it doesn't provide much benefit, but for multi page usage, this keeps the codebase clean.

Use this to simply indicate where the ProgressStepper should appear in a screen.

ProgressStepperVerticalProvider

ProgressStepperVerticalProvider is a Context Provider that holds all of the styles and states of ProgressStepperVertical.

Single Page

Usage

Declare ProgressStepperVerticalProvider in root level to use ProgressStepperVertical and access useProgressStepperVerticalContext hooks

App.js

import {
ProgressStepperVertical,
ProgressStepperVerticalProvider,
useProgressStepperVerticalContext,
} from "react-native-reanimated-progress-steps";

function App() {
const STEPS = [
{ title: "Order Recieved", description: "Your order is ready " },
{
title: "Processing",
description: "Your order is being processed ",
},
{
title: "Out for Delivery",
description: "Our Delivery Van is on the way to you.",
},
{
title: "Note from Delivery Man",
description: "Customer er meye parcel niye palaise.",
},
];
return (
<SafeAreaView>
<ProgressStepperVerticalProvider
height={500}
steps={STEPS}
initialPosition={1}
>
<ProgressStepperVerticalExample />
</ProgressStepperVerticalProvider>
</SafeAreaView>
);
}

export default App;

ProgressStepperVerticalExample.js

import { View, StyleSheet, Button, ScrollView } from "react-native";

import {
ProgressStepper,
useProgressStepperContext,
} from "react-native-reanimated-progress-steps";

function ProgressStepperVerticalExample() {
const { goToNext, goToPrevious } = useProgressStepperVerticalContext();
return (
<ScrollView>
<View style={styles.container}>
<ProgressStepperVertical />
</View>
<View style={styles.btnContainer}>
<Button title="Next" onPress={goToNext} />
<Button title="Previous" onPress={goToPrevious} />
</View>
</ScrollView>
);
}

export default ProgressStepperVerticalExample;

const styles = StyleSheet.create({
container: {
marginVertical: 64,
},
btnContainer: {
marginVertical: 2,
},
});

Default Styles

extended mode

      <ProgressStepperVerticalProvider
height={500}
steps={STEPS}
initialPosition={1}
extended
>

custom step with any valid React Component as step

 <ProgressStepperVerticalProvider
height={500}
steps={STEPS}
initialPosition={1}
extended
renderStep={(step, _) => {
return (
<View style={styles.stepContainer}>
<Text style={styles.stepTitle}>{step.title}</Text>
<Text style={styles.setpDescription}>{step.description}</Text>
</View>
);
}}
>

// ...........

const styles = StyleSheet.create({
stepContainer: {
width: 300,
},
stepTitle: {
color: 'black',
fontWeight: 'bold',
fontStyle: 'italic',
},
setpDescription: {
left: 10,
color: 'grey',
fontSize: 12,
},
});


renderInnerStep to render any valid component as inner step

<ProgressStepperVerticalProvider
height={500}
steps={STEPS}
initialPosition={1}
extended
renderStep={(step, _) => {
return (
<View style={styles.stepContainer}>
<Text style={styles.stepTitle}>{step.title}</Text>
<Text style={styles.setpDescription}>{step.description}</Text>
</View>
);
}}
renderInnerStep={() => {
return (
<Image source={require('../assets/box.png')} style={styles.image} />
);
}}
activeColor="#E44949"
trackActiveColor="#E44949"
trackWidth={3}
>
//....
const styles = StyleSheet.create({
image: {
width: 16,
height: 16,
},
});

stepStyle to further customize


<ProgressStepperVerticalProvider
height={500}
steps={STEPS}
initialPosition={1}
extended
renderStep={(step, _) => {
return (
<View style={styles.stepContainer}>
<Text style={styles.stepTitle}>{step.title}</Text>
<Text style={styles.setpDescription}>{step.description}</Text>
</View>
);
}}
renderInnerStep={() => {
return (
<Image source={require('../assets/box.png')} style={styles.image} />
);
}}
stepStyle={{
width: 34,
height: 34,
justifyContent: 'center',
alignItems: 'center',
borderRadius: 17,
borderWidth: 4,
borderColor: 'white',
}}
activeColor="#E44949"
trackActiveColor="#E44949"
trackWidth={3}
>


Multi Page

ProgressStepperVertical is ideal for single page use. But it can be used as a multipage setup as well. Just follow the Multi Page Setup Example from ProgressStepper and make sure to replace

  • ProgressStepper with ProgressStepperVertical
  • ProgressStepperProvider with ProgressStepperVerticalProvider
  • useProgressStepperContext() with useProgressStepperVerticalContext()

Props

NameOptionalTypeDescriptionDefault Value
childrenYesReactNodeThe children elements to render within the component.N/A
heightYesnumberThe height of the window.windowHeight
stepsYesArrayAn array containing the steps of the progress indicator.[]
initialPositionYesnumberThe initial position of the step indicator.0
animationDurationYesnumberDuration of the step transition animation in milliseconds.300
animationDelayYesnumberDelay before the animation starts in milliseconds.700
trackWidthYesnumberWidth of the track line.6
containerWidthYesnumberWidth of the container holding the steps.60
stepHeightYesnumberHeight of each step.60
stepStyleYesObjectStyle object for each step.{ width: 30, height: 30, borderRadius: 15, justifyContent: 'center', alignItems: 'center', position: 'relative' }
showLabelsYesbooleanWhether to show labels for the steps.true
activeColorYesstringColor of the active step.#FF0000
inactiveColorYesstringColor of the inactive steps.#DEDEDE
trackActiveColorYesstringColor of the active part of the track.#FF0000
trackInactiveColorYesstringColor of the inactive part of the track.#DEDEDE
titleContainerStyleYesObjectStyle object for the title container.{ left: 50, minWidth: 200 }
titleStyleYesObjectStyle object for the step title.{ color: 'black', fontSize: 12, fontWeight: 'bold' }
descriptionStyleYesObjectStyle object for the step description.{}
innerLabelStyleYesObjectStyle object for the inner label of each step.{ color: 'white', fontWeight: 'bold' }
extendedYesbooleanWhether the steps are in extended mode.false
renderInnerStepYesfunctionCustom rendering function for the inner step.null
renderStepYesfunctionCustom rendering function for the step.null

Hooks

useProgressStepperVerticalContext()

PropertyTypeDescription
heightnumberThe height of the component.
stepsStep[]An array containing the steps of the progress indicator.
initialPositionnumberThe initial position of the step indicator.
animationDurationnumberDuration of the step transition animation in milliseconds.
animationDelaynumberDelay before the animation starts in milliseconds.
stepHeightnumberHeight of each step.
stepStyleViewStyleStyle object for each step.
trackWidthnumberWidth of the track line.
containerWidthnumberWidth of the container holding the steps.
activeColorstringColor of the active step.
inactiveColorstringColor of the inactive steps.
showLabelsbooleanWhether to show labels for the steps.
trackActiveColorstringColor of the active part of the track.
trackInactiveColorstringColor of the inactive part of the track.
titleContainerStyleViewStyleStyle object for the title container.
titleStyleTextStyleStyle object for the step title.
descriptionStyleTextStyleStyle object for the step description.
innerLabelStyleTextStyleStyle object for the inner label of each step.
extendedbooleanWhether the steps are in extended mode.
renderInnerStep((step: Step, index: number) => React.ReactNode)Custom rendering function for the inner step.
renderStep((step: Step, index: number) => React.ReactNode)Custom rendering function for the step.
currentPositionnumberThe current position of the step indicator.
setCurrentPositionReact.Dispatch<React.SetStateAction<number>>Function to set the current position of the step indicator.
goToNext() => voidFunction to move to the next step.
goToPrevious() => voidFunction to move to the previous step.
progressSharedValue<number>The progress value for the current step.
perStepHeightnumberThe height for each step when calculating the progress indicator.