Socket
Book a DemoInstallSign in
Socket

reactjs-multi-stepper

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

reactjs-multi-stepper

This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.

latest
Source
npmnpm
Version
1.2.5
Version published
Weekly downloads
77
45.28%
Maintainers
1
Weekly downloads
 
Created
Source

React Multi Stepper

A lightweight, customizable, and reusable multi-stepper component for React.
It allows you to create step-based workflows such as onboarding, multi-step forms, or guided processes with ease.

🎬 Demo

React Multi Stepper Demo

🚀 Features

  • ✅ Easy to use and integrate into any React project
  • 🎨 Fully customizable step styles (active, completed, loading, error)
  • ⚡ Built with TypeScript for type safety
  • 🧩 Context-based state management with hooks
  • 🔄 Built-in step validation and status management
  • 🎯 Support for async operations with loading states
  • ❌ Error handling for failed step validations
  • 🧪 Tested with Vitest + React Testing Library

📦 Installation

npm install react-multi-stepper
# or
yarn add react-multi-stepper

🔨 Basic Usage

1. Wrap your app with MultiStepperProvider

import React from "react";
import { MultiStepperProvider, MultiStepper, useMultiStepper } from "react-multi-stepper";

function App() {
  return (
    <MultiStepperProvider steppers={[
      {
        id: 1,
        title: "Personal Info",
        description: "Enter your personal details",
        children: <PersonalInfoForm />
      },
      {
        id: 2,
        title: "Address",
        description: "Enter your address details",
        children: <AddressForm />
      },
      {
        id: 3,
        title: "Review",
        description: "Review and confirm",
        children: <ReviewStep />
      }
    ]}>
      <MyMultiStepper />
    </MultiStepperProvider>
  );
}

2. Create your stepper component

function MyMultiStepper() {
  const { handleNextStep, setStepStatus } = useMultiStepper();

  const validateAndProceed = async () => {
    // Set loading state
    setStepStatus("loading");

    try {
      // Simulate async validation
      await validateCurrentStep();
      
      // Mark as completed and move to next
      setStepStatus("completed");
      handleNextStep();
    } catch (error) {
      // Show error state
      setStepStatus("error");
    }
  };

  return <MultiStepper onClickNext={validateAndProceed} />;
}

🔧 Advanced Usage

Step Validation with Custom Logic

function ReactMultiStepper() {
  const { handleNextStep, setStepStatus, currentStep } = useMultiStepper();

  const validateStepContent = async () => {
    setStepStatus("loading");

    try {
      // Custom validation based on current step
      switch (currentStep) {
        case 1:
          await validatePersonalInfo();
          break;
        case 2:
          await validateAddress();
          break;
        case 3:
          await submitForm();
          break;
      }

      setStepStatus("completed");
      handleNextStep();
    } catch (error) {
      setStepStatus("error");
      console.error("Step validation failed:", error);
    }
  };

  return <MultiStepper onClickNext={validateStepContent} />;
}

Custom Step Content

const steppers = [
  {
    id: 1,
    title: "Step One",
    description: "Step one description",
    children: (
      <div className="custom-step">
        <h3>Custom Step Content</h3>
        <form>
          <input type="text" placeholder="Enter data..." />
        </form>
      </div>
    )
  },
  // ... more steps
];

🧩 API Reference

MultiStepperProvider Props

PropTypeRequiredDescription
steppersStepperType[]Array of step configurations
childrenReactNodeChild components that will have access to stepper context
optionsOptionsType(Optional) Custom icons for step statuses

StepperType Interface

PropertyTypeRequiredDescription
idnumberUnique identifier for the step
titlestringStep title displayed in the stepper
descriptionstringStep description or subtitle
childrenReactNodeContent to render for this step

OptionsType

PropertyTypeRequiredDescription
completedIconReactNodeNoIcon to display for completed steps
activeIconReactNodeNoIcon to display for the active step
errorIconReactNodeNoIcon to display for steps in error state
loadingIconReactNodeNoIcon to display for steps in loading state

MultiStepper Props

PropTypeRequiredDescription
onClickNext() => voidCallback triggered when the "Next" button is clicked

useMultiStepper Hook

Method/PropertyTypeDescription
handleNextStep() => voidMove to the next step
setStepStatus(status: StepStatus) => voidUpdate current step status
currentStepnumberCurrent active step number
totalStepsnumberTotal number of steps

Step Status Types

StatusDescription
"active"Step is currently active and ready for user interaction
"loading"Step is processing/validating (shows loading indicator)
"completed"Step has been successfully completed
"error"Step has validation errors or failed processing

FAQs

Package last updated on 13 Sep 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts