Skip to content

azizbecha/react-native-multistep

Repository files navigation

React Native MultiStep πŸš€

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. 🎨

🌟 Features ✨

  • βœ… 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. 🎨

πŸ”§ Installation πŸ“¦

  1. Install the necessary dependencies:
npm install react-native-multistep

or

yarn add react-native-multistep
  1. Import the MultiStepForm component into your app: πŸ“œ
import { MultiStepForm } from 'react-native-multistep';

βš›οΈ Props

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 βœ…

πŸ“– Usage Example 🧡

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;

🎨 Styling

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 βœ…

πŸ”„ Animations

  • Step Indicator Animation πŸŽ₯: The active step indicator includes a scale effect when selected, providing a quick visual cue to the user. πŸ”„

🀝 Contributing

See the contributing guide to learn how to contribute to the project. πŸ› οΈ

πŸ“œ License

MIT πŸ“


Made with ❀️ by Aziz Becha 🌟

About

React Native multistep forms made easy πŸš€

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published