🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

material-form-builder

Package Overview
Dependencies
Maintainers
1
Versions
90
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

material-form-builder

FormBuilder For React.js

0.22.0
latest
Source
npm
Version published
Weekly downloads
17
-89.76%
Maintainers
1
Weekly downloads
 
Created
Source

MUI logo

material form builder (MFB)

Quick Access

introduction

In react, we are always involved in implementing a structure to receive information from the user The implementation of these structures may take us a lot of time My goal is to minimize this time You can create a branch of inputs with different structures with a few lines of code.

Installation

Dependencies

Material UI (^5.x.x) is available as an npm package.

npm install @mui/material @mui/x-date-pickers @mui/icons-material @emotion/react @emotion/styled dayjs

material-form-builder

npm:

npm install material-form-builder

yarn:

yarn add material-form-builder

basic usage:

import React, { useRef } from 'react'
import { FormBuilder } from 'material-form-builder'

const App = () => {
    const builderRef = useRef(null)
    const getValues = () => {
        const values = builderRef.current?.getValues()
    }
    const clear = () => {
        builderRef.current?.clear()
    }
    return (
        <Fragment>
            <Box>
                <FormBuilder
                    inputs={[
                        {
                            type: 'text',
                            selector: 'person_name',
                            label: 'Name',
                        },
                        {
                            type: 'text',
                            selector: 'person_family',
                            label: 'Family',
                        },
                    ]}
                    ref={builderRef}
                />
            </Box>
            <Box mt={1}>
                <Button color="success" onClick={getValues}>
                    Get
                </Button>
                <Button color="secondary" onClick={setValues}>
                    Set
                </Button>
                <Button color="primary" onClick={clear}>
                    clear
                </Button>
            </Box>
        </Fragment>
    )
}

Component Props:

keydescriptionlink
inputsinputs datausage
refreact ref-

Ref Avilable Methods:

keydescriptionusage
getValuesget value data from form builderusage
setValuesset your data into inputsusage
clearclear all inputs datausage

Get Values Prop

builderRef.current?.getValues() usage:

{
    data: {
        person_name: 'ENTERED VALUE'
        person_family: 'ENTERED VALUE'
    },
    validation: {
        status: boolean,
        inputs: []
    }
}

Set Values Prop

builderRef.current?.setValues() usage:

builderRef.current
    ?.setValues({
        tid: 1,
        person_name: 'john',
        person_family: 'doe',
    })
    .then(() => {
        console.log('all promises were fulfilled !')
    })

The data entered in the inputs will be set and if additional values are received, they will be returned

Clear Prop

builderRef.current?.clear() usage:

builderRef.current?.clear().then(() => {
    console.log('all promises were fulfilled !')
})

Type Of Inputs

typedescriptionusage
texttext inputtext input usage
numbernumber inputnumber input usage
checkboxcheckbox inputcheckbox input usage
passwordpassword inputpassword input usage
autocompleteautocomplete inputautocomplete input usage
mobilemobile inputmobile input usage
otpotp inputotp input usage
maskmask inputmask input usage
datedate inputdate input usage
timetime inputtime input usage
datetimedatetime inputdatetime input usage
filefile inputfile input usage
itemsitems inputitems input usage
customcustom inputcustom input usage

Basic Input Props

keytypedescriptionsample
selectorstring--
defaultValueInput Value Type--
requiredboolean--
visibleboolean--
wrapperfunction--
onChangeValuefunction--
getMutatorfunction--
setMutatorfunction--

License

This project is licensed under the terms of the MIT license.

Sponsoring services

mentasystem.net

back to top

Keywords

form-builder

FAQs

Package last updated on 13 May 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