🪄 Multi step forms with in built validations

Overview

Project logo

License npm bundle size (version) Snyk Version

react-wizardry is a data-driven smart wizard component for creating powerful forms with in built validations.


demo

Demo

Features

  • Data driven API
  • In built validations
  • 💪 Built with Typescript
  • 💡 Intuitive stepper interface
  • 🎨 Customizable Theme

Table of Contents

📦 Installation

Install the package via npm or yarn

npm install react-wizardry
yarn add react-wizardry

🚀 Getting Started

The component takes a pages collection and renders the pages in a stepper interface.The pages appear in the order they are passed in the pages collection.

The example shows a simple wizard with two pages.

<Wizard
  pages={[
    {
      title: "Introduction",
      fields: [
        {
          label: "Name",
          name: "name",
          type: "text",
          isRequired: true,
        },
      ],
  },
  {
    title: "Contact",
    fields: [
      {
        label: "Email",
        name: "email",
        type: "email",
        isRequired: true,
      },
    ],
 }
},

⚙️ Properties

Name Description Default
strict Validation rules are applied to all inputs that have been marked for validation or that are required. The component prevents the user from moving on until the current step's errors have been fixed. false
theme Theme object for customized styling
highlightFieldsOnValidation Highlights the fields when the validation fails or succeeds false
pages Collection of Page object
onFinish Callback executed on final step
RTL Enables right to left mode false

Page

Page object is at the core of the wizard. Page object is used to define the title, description, fields, and validation rules for a page.

Name Description Type
fields Fields of the Page Array
finishMessage Custom message to be displayed on finish operation String
globalFormErrorMessage Global error message to be displayed on validation failures String
isActive Indicates whether the page is active or not Boolean
onChange Callback executed when any of the Form field value changes(Internal) Function
state State of the Page. can be NOT_VALIDATED, SUCCESS, FAIL, String
title Title of the Page String

Every page is in the NOT_VALIDATED state by default.

Here is an examples how to define pages in the wizard. We are defining two pages with two fields.

<Wizard
  pages={[
    {
      title: "Introduction",
      fields: [
        {
          label: "First Name",
          name: "firstName",
          type: "text",
          isRequired: true,
        },
        {
          label: "Last Name",
          name: "lastName",
          type: "text",
          isRequired: true,
        },
      ],
  },
  {
    title: "Contact",
    fields: [
      {
        label: "Email",
        name: "email",
        type: "email",
        isRequired: true,
      },
      {
        name: "Phone number",
        label: "Phone",
        type: "phone",
        isRequired: true,
      },
    ],
 }
},

Form field

Form field represents an input field in the wizard. Form field is used to define the label, type, validation rules, and other properties.

Name Description Type
isRequired Marks the field as required boolean
label Label for the field string
name Name of the Field string
selectOptions Use this prop when type is "select" Array
type Type of Field InputType
validate Enables validation for the field boolean
validationMessage Custom validation message to be shown on validation failure boolean

Fields marked as required are automatically validated. If you set isRequired to false and validate to true, the wizard will validate and flag the errors, but the step itself will not be marked as invalid.

In the example below we are defining two fields and making them required.

<Wizard
  pages={[
    {
      title: "Introduction",
      fields: [
        {
          label: "First Name",
          name: "firstName",
          type: "text",
          isRequired: true,
        },
        {
          label: "Last Name",
          name: "lastName",
          type: "text",
          validate: true,
        },
      ],
  },
]}

Here only the First Name field is required. The last name field will be validated if the user enters a value.

Form field types

Form field supports the following types:

  • text: Text input field
  • email: Email input field
  • phone: Phone input field
  • number: Number input field
  • password: Password input field
  • textarea: Textarea input field
  • select: Select input field
  • checkbox: Checkbox input field
  • radio: Radio input field
  • datetime: DateTime input field
  • file: File input field

All the above input types comes with inbuilt validation.

Accessing the wizard data

The onFinish callback receives the wizard data with each key representing a page.

For the getting started example, the onFinish callback will receive an object with the following structure:

{
  "introduction": {
    "firstName": "<entered name>",
    "lastName": "<entered name>",
  },
  "contact": {
    "email": "<entered email id>";
    "phone": "<entered phone number>",
  }
}

Custom validation messages

Validation messages are enabled by default for all fields. However, the validationMessage property allows you to customize the message for each field.

<Wizard
  pages={[
    {
      title: "Introduction",
      fields: [
        {
          label: "First Name",
          name: "firstName",
          type: "text",
          isRequired: true,
          validationMessage: "Please enter your first name",
        },
      ],
  },
]}

🎨 Theme

Customize the look and feel of the Wizard through the theme object.

Name Description Data Type Default
background Background color of the wizard string #f8f8f8
fail Colour to signify failed state string #de1738
formFieldBackground Background color of the Form field string #ffffff
formFieldBorder Border colour of the form field string #dcdcdc
inputBackground Background color of the native input control string #e8e8e8
inputTextColor Fore color of the text inside the native input control string #000000
primary Primary colour. This color will be the predominant color string #007fff
success Colour to signify a success state string #1db954
tabColor Colour of the tab string #f8f8f8
tabLineColor Colour of the line that runs through all the tabs string #ccc
textColor Colour of all texts string #000000

Here is a short example of how to use the theme object.

<Wizard
  theme={{
    primary: "#007fff",
    background: "#000",
    textColor: "#fff",
    formFieldBackground: "#282828",
    formFieldBorder: "#000",
    success: "#519259",
    fail: "#cf352e",
    inputBackground: "#464646",
    inputTextColor: "#fff",
    tabLineColor: "#464646",
    tabColor: "#7d7d7d",
  }}
/>

CodeSandbox examples

  1. Basic Wizard
  2. Complex Wizard
  3. Wizard with custom theme
  4. RTL

⛏️ Built With

  • React - A JavaScript library for building user interfaces.
  • Typescript - TypeScript is a typed superset of JavaScript that compiles to plain JavaScript.
  • SCSS - A CSS preprocessor and compiler.
  • Webpack - Webpack is a module bundler that packs multiple modules into a single file.
  • Eslint - ESLint is a linter for JavaScript and JSX.
  • Prettier - Prettier is a tool to format code.

✍️ Authors

You might also like...

Solid Forms provides several form control objects useful for making working with forms easier.

Solid Forms Solid Forms provides several form control objects useful for making working with forms easier. Demos and examples below. # solidjs yarn ad

Jan 2, 2023

Multi-step wizard helpers for Alpine.js

Multi-step wizard helpers for Alpine.js

Alpine Wizard This package provides an Alpine directive (x-wizard) and a magic helper ($wizard) that allow you to quickly build multi-step wizards usi

Dec 23, 2022

Easy, lightweight multi-step experiences.

Easy, lightweight multi-step experiences.

Steppp Steppp is a small library for quickly creating multi-step forms, carousels, and other experiences. It emphasizes a flexible developer experienc

Dec 7, 2022

🦩 Joi like validations for TypeScript

🦩 Computed Types Runtime validation types for TypeScript. Computed-Types (formerly: Funval) is a strongly-typed validation library for TypeScript. Us

Jan 4, 2023

Simple and basic javascript form validations

JavaScript-Form-Validations Simple and basic javascript form validations Table of Validations: S. No. Type of validation Link 1 Non-empty text field h

Dec 17, 2022

Node.js package with a customized HTTP and HTTPS agents to prevent SSRF with hosts validations and custom DNS feature.

http-agent-dns This is a Node.js package with a customized HTTP and HTTPS agents to prevent SSRF with hosts validations with a possibility to use a cu

Jul 21, 2022

The responsive CSS animation framework for creating unique sliders, presentations, banners, and other step-based applications.

Sequence.js The responsive CSS animation framework for creating unique sliders, presentations, banners, and other step-based applications. Sequence.js

Dec 20, 2022

Each commit is a step of training.

Each commit is a step of training.

This project was bootstrapped with Create React App. Below you will find some information on how to perform common tasks. You can find the most recent

Jun 18, 2022

Wordle is a simple word game created by a Software Engineer Wardle. I made this simple helper app to show remaining words in each step.

Wordle is a simple word game created by a Software Engineer Wardle. I made this simple helper app to show remaining words in each step.

Wordle Helper Wordle is a simple word game created by a Software Engineer Wardle. I made this simple helper app to show remaining words in each step.

Oct 24, 2022

How to implement Step-up Authentication using Amazon Cognito

How to implement Step-up Authentication using Amazon Cognito

How to implement Step-up Authentication using Amazon Cognito This repository contains accompanying source code for the AWS Blog post, How to implement

Dec 15, 2022

AWS Step Functions Workflows Collection

AWS Step Functions Workflows Collection This repo contains Step Functions workflows that shows how to orchestrate multiple services into business-crit

Dec 25, 2022

Hadmean is an internal tool generator. It is language agnostic, schema driven, extremely customizable, featured packed, user-friendly and has just one installation step.

Hadmean is an internal tool generator. It is language agnostic, schema driven, extremely customizable, featured packed, user-friendly and has just one installation step.

Hadmean Report a Bug · Request a Feature · Ask a Question Table of Contents About Quick Demo Motivation Why you should try Hadmean Getting Started Pre

Dec 29, 2022

VSCode Extension - Preview for AWS Step Functions

VSCode Extension - Preview for AWS Step Functions

VS Code - AWS Step Functions Preview This extension lets you see what your state machine looks like in graphical format. This will help you in writing

Sep 19, 2022

A refined tool for exploring open-source projects on GitHub with a file tree, rich Markdown and image previews, multi-pane multi-tab layouts and first-class support for Ink syntax highlighting.

A refined tool for exploring open-source projects on GitHub with a file tree, rich Markdown and image previews, multi-pane multi-tab layouts and first-class support for Ink syntax highlighting.

Ink codebase browser, "Kin" 🔍 The Ink codebase browser is a tool to explore open-source code on GitHub, especially my side projects written in the In

Oct 30, 2022

proxy 🦄 yxorp is your Web Proxy as a Service (SAAS) Multi-tenant, Multi-Threaded, with Cache & Article Spinner

proxy 🦄 yxorp is your Web Proxy as a Service (SAAS) Multi-tenant, Multi-Threaded, with Cache & Article Spinner

proxy 🦄 yxorp is your Web Proxy as a Service (SAAS) Multi-tenant, Multi-Threaded, with Cache & Article Spinner. Batteries are included, Content Spinning and Caching Engine, all housed within a stunning web GUI. A unique high-performance, plug-and-play, multi-threaded website mirror and article spinner

Dec 30, 2022

Bot WhatsApp multi device / multi perangkat menggunakan lib / api baileys-md. Give star ⭐

Bot WhatsApp multi device / multi perangkat menggunakan lib / api baileys-md. Give star ⭐

Requirements • Installation • Thanks to • Official Group Bot • Donate Information Chika-Md adalah bot yang awalnya memakai base dari Hisoka-Morou. Chi

Dec 25, 2022

whatsapp api to remote your whatsapp device. Support multi device, multi client. Still update to more feature. Please fork, star, donate and share.

whatsapp api to remote your whatsapp device. Support multi device, multi client. Still update to more feature. Please fork, star, donate and share.

Ndalu-wa-client DEPENDENCIES : { "@adiwajshing/baileys": "^4.2.0", "@adiwajshing/keyed-db": "^0.2.4", "axios": "^0.27.2", "body-parser

Jan 4, 2023

Build forms in React, without the tears 😭

Build forms in React, without the tears 😭

Build forms in React, without the tears. Visit https://formik.org to get started with Formik. Organizations and projects using Formik List of organiza

Jan 5, 2023

📋 React Hooks for forms validation (Web + React Native)

📋 React Hooks for forms validation (Web + React Native)

English | 繁中 | 简中 | 日本語 | 한국어 | Français | Italiano | Português | Español | Русский | Deutsch | Türkçe Features Built with performance and DX in mind

Dec 29, 2022
Comments
Releases(0.13.4)
Owner
Prabhu Murthy
Prabhu Murthy
Simple and basic javascript form validations

JavaScript-Form-Validations Simple and basic javascript form validations Table of Validations: S. No. Type of validation Link 1 Non-empty text field h

MAINAK CHAUDHURI 23 Dec 17, 2022
Validate your forms, frontend, without writing a single line of javascript

Parsley JavaScript form validation, without actually writing a single line of JavaScript! Version 2.9.2 Doc See index.html and doc/ Requirements jQuer

Guillaume Potier 9k Dec 27, 2022
jQuery library to validate html forms. compatible with bootstrap v4 and bootstrap v3

jQuery form validation jQuery form validation is a library that helps you to validate your HTML form, it's completable with both Bootstrap 3 and Boots

Bassam Nabriss 33 Jun 10, 2021
Tag-input - A versetile tag input component built with Vue 3 Composition API

TagInput A versetile tag input component built with Vue 3 Composition API. Please read this article to learn how to build this package step by step an

Mayank 12 Oct 12, 2022
A better way for new feature introduction and step-by-step users guide for your website and project.

Intro.js v3 Lightweight, user-friendly onboarding tour library Where to get You can obtain your local copy of Intro.js from: 1) This github repository

usablica 21.7k Jan 2, 2023
🛠️⚡ Step-by-step tutorial to build a modern JavaScript stack.

JavaScript Stack from Scratch Welcome to my modern JavaScript stack tutorial: JavaScript Stack from Scratch. ?? This is the V2 of the tutorial, major

Jonathan Verrecchia 19.5k Jan 4, 2023
Full source-code for the step-by-step tutorial on how to use Phaser + Colyseus together.

Phaser: Real-time Multiplayer with Colyseus Full source-code for the step-by-step tutorial on how to use Phaser + Colyseus together. Live Demo See ste

Colyseus 19 Dec 24, 2022
A simple step by step tooltip helper for any site

Tooltip Sequence A minimalistic set of tooltips on your app. What it does So suppose you create a Web Application and you want to take your users or a

Sooraj Sivadasan Nair 299 Dec 21, 2022
A light-weight user's step-by-step guide for your website using Vanilla JS.

WebTour JS A light-weight user's step-by-step guide for your website using Vanilla JS. Features User's walkthrough - can be used to guide user's to yo

JM de Leon 23 Nov 21, 2022