npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@octopuslabs/react-multi-step-form

v0.1.0

Published

A highly customizable, type-safe React multi-step form builder with progress tracking, validation, and beautiful UI components

Readme

React Multi-Step Form Builder

A highly customizable, type-safe React multi-step form library with progress tracking, validation, and beautiful UI components. Build complex onboarding flows, surveys, or registration processes with ease using JSON configuration.

npm version License: MIT

Features

  • 🎨 JSON-Powered - Define your entire form structure in a simple JSON configuration
  • Smooth Transitions - Fluid, animated transitions between form steps
  • 📊 Progress Tracking - Visual progress bar shows users their position in the flow
  • Built-in Validation - Support for required fields and custom regex validation
  • 🎯 Rich Form Elements - Text, email, password, select, textarea, radio, and checkbox groups
  • 🔄 State Persistence - Save and restore form progress
  • 💪 TypeScript - Fully typed for better developer experience
  • 🎭 Customizable - Themeable components with Tailwind CSS
  • Accessible - Built with accessibility in mind

Installation

# npm
npm install @yourscope/react-multi-step-form

# yarn
yarn add @yourscope/react-multi-step-form

# pnpm
pnpm add @yourscope/react-multi-step-form

Note: This library requires React 18+ and uses Tailwind CSS for styling.

Quick Start

1. Basic Usage

import React, { useState, useEffect } from 'react';
import { MultiStepForm, FormConfig, FormData } from '@yourscope/react-multi-step-form';

function App() {
  const [formConfig, setFormConfig] = useState<FormConfig | null>(null);

  useEffect(() => {
    // Load your form configuration
    fetch('/path/to/form-config.json')
      .then(res => res.json())
      .then(data => setFormConfig(data));
  }, []);

  const handleSubmit = (formData: FormData) => {
    console.log('Form submitted:', formData);
    // Send to your API, etc.
  };

  if (!formConfig) return <div>Loading...</div>;

  return (
    <div className="min-h-screen bg-gray-900 flex items-center justify-center p-4">
      <div className="w-full max-w-2xl">
        <MultiStepForm config={formConfig} onSubmit={handleSubmit} />
      </div>
    </div>
  );
}

2. Form Configuration Example

Create a JSON configuration file:

{
  "formId": "user-onboarding",
  "title": "Welcome Onboarding",
  "welcome": {
    "title": "Welcome!",
    "message": "Let's get you set up in just a few steps.",
    "buttonText": "Get Started"
  },
  "steps": [
    {
      "id": "step1",
      "title": "Personal Information",
      "description": "Tell us about yourself",
      "fields": [
        {
          "id": "fullName",
          "label": "Full Name",
          "type": "text",
          "placeholder": "John Doe",
          "required": true
        },
        {
          "id": "email",
          "label": "Email Address",
          "type": "email",
          "placeholder": "[email protected]",
          "required": true,
          "validationRegex": "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$",
          "validationMessage": "Please enter a valid email address"
        }
      ]
    },
    {
      "id": "step2",
      "title": "Preferences",
      "description": "Customize your experience",
      "fields": [
        {
          "id": "interests",
          "label": "What are you interested in?",
          "type": "checkbox-group",
          "required": true,
          "options": [
            { "value": "tech", "label": "Technology" },
            { "value": "design", "label": "Design" },
            { "value": "business", "label": "Business" }
          ],
          "allowOther": true
        }
      ]
    }
  ],
  "completion": {
    "title": "All Done!",
    "message": "Thank you for completing the form.",
    "buttonText": "Start Over"
  }
}

3. Save/Load Progress

import React, { useRef } from 'react';
import { MultiStepForm, MultiStepFormHandle, FormConfig } from '@yourscope/react-multi-step-form';

function App() {
  const formRef = useRef<MultiStepFormHandle>(null);
  const formConfig: FormConfig = /* your config */;

  const saveProgress = () => {
    if (formRef.current) {
      const state = formRef.current.getState();
      localStorage.setItem('formProgress', JSON.stringify(state));
      alert('Progress saved!');
    }
  };

  const loadProgress = () => {
    const saved = localStorage.getItem('formProgress');
    if (saved && formRef.current) {
      formRef.current.restoreState(JSON.parse(saved));
      alert('Progress restored!');
    }
  };

  return (
    <>
      <MultiStepForm
        ref={formRef}
        config={formConfig}
        onSubmit={(data) => console.log(data)}
      />
      <button onClick={saveProgress}>Save</button>
      <button onClick={loadProgress}>Load</button>
    </>
  );
}

API Reference

Components

<MultiStepForm />

The main form component.

Props:

  • config: FormConfig - The form configuration object (required)
  • onSubmit?: (formData: FormData) => void - Callback when form is submitted

Ref Methods (via MultiStepFormHandle):

  • getState(): FormState - Get current form state
  • restoreState(state: FormState): void - Restore saved state

Types

interface FormConfig {
  formId: string;
  title: string;
  welcome?: WelcomeConfig;
  steps: FormStep[];
  completion?: CompletionConfig;
}

interface FormStep {
  id: string;
  title: string;
  description?: string;
  fields: FormField[];
}

interface FormField {
  id: string;
  label: string;
  type: FormFieldType;
  placeholder?: string;
  required?: boolean;
  validationRegex?: string;
  validationMessage?: string;
  options?: Array<{ value: string; label: string }>;
  allowOther?: boolean;
}

type FormFieldType =
  | 'text'
  | 'email'
  | 'password'
  | 'tel'
  | 'number'
  | 'textarea'
  | 'select'
  | 'radio-group'
  | 'checkbox-group';

type FormData = Record<string, string>;

Field Types

| Type | Description | |------|-------------| | text | Single-line text input | | email | Email input with validation | | password | Password input (masked) | | tel | Telephone number input | | number | Numeric input | | textarea | Multi-line text input | | select | Dropdown selection | | radio-group | Single choice from options | | checkbox-group | Multiple choice from options |

All radio-group and checkbox-group fields support allowOther: true to add an "Other" option with a text input.

Styling

This library uses Tailwind CSS. Make sure Tailwind is configured in your project:

npm install -D tailwindcss postcss autoprefixer
npx tailwindcss init

Update your tailwind.config.js:

module.exports = {
  content: [
    "./src/**/*.{js,jsx,ts,tsx}",
    "./node_modules/@yourscope/react-multi-step-form/dist/**/*.js"
  ],
  // ... rest of config
}

Examples

Check out the examples directory for a full working demo.

To run the demo locally:

git clone https://github.com/octopuslabs-fl/Generic-Form-Builder.git
cd Generic-Form-Builder
npm install
npm run dev

Development

Building the Library

# Build for production
npm run build:lib

# This generates:
# - dist/index.mjs (ES module)
# - dist/index.cjs (CommonJS)
# - dist/index.d.ts (TypeScript types)

Running the Demo

npm run dev

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT © [Your Name]

Support


Note: Before publishing to npm, remember to:

  1. Update package name in package.json (remove @yourscope/ or use your actual scope)
  2. Add your author information
  3. Update repository URLs
  4. Add a LICENSE file
  5. Test the build with npm run build:lib