An open API service indexing awesome lists of open source software.

https://github.com/azizbecha/react-native-multistep

React Native multistep forms made easy ๐Ÿš€
https://github.com/azizbecha/react-native-multistep

forms npm react-native

Last synced: 2 months ago
JSON representation

React Native multistep forms made easy ๐Ÿš€

Awesome Lists containing this project

README

          

# 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:

```bash
npm install react-native-multistep
```

or

```bash
yarn add react-native-multistep
```

2. Import the `MultiStepForm` component into your app: ๐Ÿ“œ

```tsx
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` | - | Custom style for the **root container**. ๐Ÿ–Œ๏ธ |
| `nextButtonStyle` (optional) | `StyleProp` | - | Custom style for the **Next button** ๐Ÿ”น |
| `previousButtonStyle` (optional) | `StyleProp` | - | Custom style for the **Previous button** ๐Ÿ”™ |
| `doneButtonStyle` (optional) | `StyleProp` | - | Custom style for the **Done button** โœ… |
| `stepsContainerStyle` (optional) | `StyleProp` | - | Custom style for the **step indicators container** ๐Ÿ”ข |
| `activeStepStyle` (optional) | `StyleProp` | - | Custom style for **active step indicators** ๐Ÿ”ฅ |
| `inactiveStepStyle` (optional) | `StyleProp` | - | Custom style for **inactive step indicators** โ„๏ธ |
| `contentContainerStyle` (optional) | `StyleProp` | - | Custom style for the **content container** ๐Ÿ“ |
| `buttonsContainerStyle` (optional) | `StyleProp` | - | 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 ๐Ÿงต

```tsx
import React from 'react';
import { MultiStepForm } from 'react-native-multistep';
import { Text, View } from 'react-native';

const App = () => {
const stepsContent = [
Step 1: Personal Information ๐Ÿ‘ค,
Step 2: Address ๐Ÿ“,
Step 3: Review โœ…,
];

const handleStepChange = (currentStep: number) => {
console.log(`Current Step: ${currentStep}`);
};

const handleComplete = () => {
console.log('Form Completed! ๐ŸŽ‰');
};

return (

);
};

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](CONTRIBUTING.md) to learn how to contribute to the project. ๐Ÿ› ๏ธ

## ๐Ÿ“œ License

MIT ๐Ÿ“

---

Made with โค๏ธ by [Aziz Becha](https://azizbecha.com) ๐ŸŒŸ