MultiStep
A component for creating guided, multi-step experiences like onboarding flows, wizards, and complex forms.
MultiStep
The MultiStep component provides a structured way to build guided, step-by-step user experiences. It's ideal for onboarding flows, wizards, and breaking down complex forms into manageable sections.
Features
- Integrated Navigation: Built-in next, back, and skip functionality
- Progress Indicator: Shows users where they are in the process
- Animated Transitions: Smooth transitions between steps
- Completion Handler: Execute code when the user completes all steps
- Customizable Header: Optional header with back button and progress display
- Cancel Option: Allow users to exit the flow at any point
- Custom or Automatic Sizing: Automatically fits content or use custom dimensions
Import
Props
MultiStep Props
Prop | Type | Default | Description |
---|---|---|---|
children | ReactNode | — | Step components to be rendered within the multi-step flow |
onComplete | () => void | — | Function called when all steps are completed |
onClose | () => void | — | Function called when the flow is closed or canceled |
showHeader | boolean | true | Whether to show the header with back button and progress indicator |
hideBackOnFirstStep | boolean | false | Whether to hide the back button on the first step |
headerTitle | string | — | Title text to display in the header |
backText | string | "Back" | Text for the back button |
nextText | string | "Continue" | Text for the next/continue button |
skipText | string | "Skip" | Text for the skip option |
showSkip | boolean | false | Whether to show a skip option |
onSkip | () => void | — | Function called when the skip option is selected |
height | number | — | Custom height for the component |
width | number | — | Custom width for the component |
style | StyleProp<ViewStyle> | — | Additional styles for the container |
Step Props
Prop | Type | Default | Description |
---|---|---|---|
children | ReactNode | — | Content to display within this step |
hasNextButton | boolean | true | Whether to show the next/continue button |
nextLabel | string | — | Custom text for the next button (overrides parent's nextText) |
nextDisabled | boolean | false | Whether the next button should be disabled |
onNext | () => void | Promise<void> | — | Custom handler for next button (can be async) |
Usage Examples
Basic Usage
Custom Step Navigation
Skippable Steps
With Form Validation
Integration Examples
Onboarding Flow
Feature Tutorial
Best Practices
Step Complexity
- Keep Steps Focused: Each step should focus on a single task or piece of information
- Logical Progression: Order steps in a logical sequence from simple to complex
- Balance Step Count: Too many steps can frustrate users, while too few might overwhelm them with information
Validation
- Validate at the Step Level: Use the
onNext
prop to validate data before proceeding - Clear Error Messages: When validation fails, provide clear guidance on how to fix issues
- Prevent Data Loss: Don't clear form data when a user navigates backward
User Experience
- Show Progress: Always indicate to users where they are in the process
- Allow Exit: Provide a way for users to exit the flow, especially for optional processes
- Save Progress: For longer flows, consider saving progress to allow users to continue later
Accessibility
- Screen Reader Support: Ensure the component and its children are accessible to screen readers
- Keyboard Navigation: Support keyboard navigation for desktop environments
- Sufficient Contrast: Maintain readable contrast for progress indicators and navigation elements
Implementation Details
The MultiStep component uses React's state management to track the current step index and handle navigation between steps. It accepts Step
components as children, which are rendered based on the current step index.
The component employs React Native's Animated
API to create smooth transitions between steps, sliding content horizontally as users navigate through the flow.
The progress indicator at the top of the component calculates its width based on the current step index and total number of steps, providing users with a visual representation of their progress.
For navigation, the component offers built-in "next" and "back" functionality, with customizable button text. Custom navigation logic can be implemented through the onNext
prop of each Step component.
Notes
- When using custom dimensions with
height
andwidth
props, ensure there's enough space for content - For form validation, remember that
onNext
can return a Promise for asynchronous validation - If you need to access the current step index, pass a ref to the MultiStep component and use the exposed methods
- The component automatically fits content height by default unless a fixed height is specified