A flexible and animated multi-step form component for React Native, allowing you to easily create forms with multiple steps. π The component provides step indicators, transition animations, and customizable buttons. π¨
- β Step Indicator: Displays a dynamic indicator to show the current step and progress. π
- β Animations: Includes an animated scale effect on the active step indicator. π
- β Customizable Buttons: Custom labels and styles for the back, next, and done buttons. π
- β Customizable Styles: Easily customize every part of the form, including content container, step indicators, buttons, etc. π¨
- Install the necessary dependencies:
npm install react-native-multistep
or
yarn add react-native-multistep
- Import the
MultiStepForm
component into your app: π
import { MultiStepForm } from 'react-native-multistep';
Prop | Type | Default | Description |
---|---|---|---|
stepsContent (required) |
React.ReactNode[] |
- | An array of React nodes, where each node represents the content for each step. ποΈ |
onStepChange (optional) |
(currentStep: number) => void |
- | A callback triggered whenever the step changes. π |
onStepForward (optional) |
(currentStep: number) => void |
- | A callback triggered when navigating to the next step. βοΈ |
onStepBackward (optional) |
(currentStep: number) => void |
- | A callback triggered when navigating to the previous step. π |
backButtonLabel (optional) |
string |
Back |
Label for the Back button π |
nextButtonLabel (optional) |
string |
Next |
Label for the Next button |
doneButtonLabel (optional) |
string |
Done |
Label for the Done button β |
onComplete (optional) |
() => void |
- | A callback triggered when the form is completed. π |
style (optional) |
StyleProp<ViewStyle> |
- | Custom style for the root container. ποΈ |
nextButtonStyle (optional) |
StyleProp<ViewStyle> |
- | Custom style for the Next button πΉ |
previousButtonStyle (optional) |
StyleProp<ViewStyle> |
- | Custom style for the Previous button π |
doneButtonStyle (optional) |
StyleProp<ViewStyle> |
- | Custom style for the Done button β |
stepsContainerStyle (optional) |
StyleProp<ViewStyle> |
- | Custom style for the step indicators container π’ |
activeStepStyle (optional) |
StyleProp<ViewStyle> |
- | Custom style for active step indicators π₯ |
inactiveStepStyle (optional) |
StyleProp<ViewStyle> |
- | Custom style for inactive step indicators βοΈ |
contentContainerStyle (optional) |
StyleProp<ViewStyle> |
- | Custom style for the content container π |
buttonsContainerStyle (optional) |
StyleProp<ViewStyle> |
- | Custom style for the footer buttons container βοΈ |
lineColor (optional) |
string |
- | Custom color for the line between indicators β |
activeLineColor (optional) |
string |
- | Custom color for the active line between indicators β |
import React from 'react';
import { MultiStepForm } from 'react-native-multistep';
import { Text, View } from 'react-native';
const App = () => {
const stepsContent = [
<Text>Step 1: Personal Information π€</Text>,
<Text>Step 2: Address π</Text>,
<Text>Step 3: Review β
</Text>,
];
const handleStepChange = (currentStep: number) => {
console.log(`Current Step: ${currentStep}`);
};
const handleComplete = () => {
console.log('Form Completed! π');
};
return (
<MultiStepForm
stepsContent={stepsContent}
onStepChange={handleStepChange}
onComplete={handleComplete}
backButtonLabel="Go Back π"
nextButtonLabel="Next Step βΆοΈ"
doneButtonLabel="Finish β
"
style={{ padding: 20 }}
nextButtonStyle={{ backgroundColor: 'blue' }}
previousButtonStyle={{ backgroundColor: 'gray' }}
doneButtonStyle={{ backgroundColor: 'green' }}
activeStepStyle={{ backgroundColor: 'blue' }}
inactiveStepStyle={{ backgroundColor: 'lightgray' }}
/>
);
};
export default App;
The component uses StyleSheet.create
for default styles. Customize your form by passing the relevant props:
- Root Container:
style
ποΈ - Step Indicator Container:
stepsContainerStyle
π’ - Active/Inactive Step Indicators:
activeStepStyle
,inactiveStepStyle
π₯ - Content Area:
contentContainerStyle
π - Footer Buttons Container:
buttonsContainerStyle
βοΈ - Back Button:
previousButtonStyle
π - Next Button:
nextButtonStyle
βΆοΈ - Done Button:
doneButtonStyle
β
- Step Indicator Animation π₯: The active step indicator includes a scale effect when selected, providing a quick visual cue to the user. π
See the contributing guide to learn how to contribute to the project. π οΈ
MIT π
Made with β€οΈ by Aziz Becha π