1.3.1 • Published 10 months ago

react-json-form-factory v1.3.1

Weekly downloads
-
License
ISC
Repository
github
Last release
10 months ago

React Form Builder

A dynamic form builder component for React applications. This component allows you to create customizable forms with various input types and validations.

Features

  • Supports multiple input types: text, password, checkboxes, radio, dropdown, date, datetime-local, file input, number, textarea.
  • Customizable form title and submit button.
  • Validations for required fields, regex patterns, min/max values, and max checked items.
  • Displays error messages for validation failures.

Installation

  npm install react-json-form-factory

Usage

import FormBuilder from "react-json-form-factory"

const formFields=[
    {
        "type": "text",
        "name": "firstName",
        "label": "First Name",
        "value": "",
        "placeholder": "Enter your first name",
    },
    {
        "type": "text",
        "name": "lastName",
        "label": "Last Name",
        "value": "",
        "placeholder": "Enter your last name",
    },
    {
        "type": "email",
        "name": "email",
        "label": "Email",
        "value": "",
        "placeholder": "Enter your email",
    }
]

function App() {
  return <FormBuilder fields={formFields} title={{"text": "My Form"}}/>
}

App Screenshot

Supported Parameters for Forms

ParameterTypeSignificance
stylesObjectused to change default colors and sizes
gridColumnsStringmaximum number of columns in a form
gapStringGap in px, rem or other units between each field
fieldsList of ObjectsList of fields in the order you want to display them
titleObjectObject with the title text and classes to be applied to it
submit_btnobjectObject with the submit button text and classes
onSubmitFunction or StringFunction to be called while submitting (fields is passed to it), If a string then a POST request will me made to the URL, and if null then the values will be console logged

Supported Parameters for Field

ParameterTypeForSignificance
typeStringAllUsed to describe the type of input field
nameStringAllUsed to describe the name of the input field must be unique
gridSpanIntegerAllNumber of grid cells a field must take
labelStringAllUsed to give label to the field
placeholderStringAllUsed to give placeholder to the field
valueStringAllDefault value of the field
requiredBoolAllMakes the field required
regexRegexAllCustom validations
minIntegernumber, date, datetime-localUsed to give min value to the field
maxIntegernumber, date, datetime-localUsed to give max value to the field
stepIntegernumber, date, datetime-localUsed to give step size to the field
minCheckedIntegerCheckboxesDefines the minimum number of checkboxes a user must select
maxCheckedIntegerCheckboxesDefines the maximum number of checkboxes a user can select
customValidationFunctionAllCustom validations using function. The value is passed to the function and it must return true or false

Authors

1.3.1

10 months ago

1.3.0

10 months ago

1.2.3

10 months ago

1.2.2

10 months ago

1.2.1

10 months ago

1.2.0

10 months ago

1.1.0

10 months ago

1.0.3

10 months ago

1.0.2

10 months ago

1.0.1

10 months ago

1.0.0

10 months ago