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 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-basic-form

v1.1.93

Published

React form builder

Readme

react-basic-form


Form builder for React

NPM version npm download

Install

npm install --save react-basic-form

react-basic-form

Usage

Example 1

import React from 'react';
import { render } from 'react-dom';
import Form from 'react-basic-form';
// import 'react-basic-form/dist/style.css'; //optional

render(
  <Form
    onSubmit={data => console.log(data)}
    validations={{
      email: value => emailRegex.test(value),
    }}
    errorMessages={{
      email: 'Please check your email address.',
    }}
  >
    <Form.Element label="Full Name" name="fullname" required />
    <Form.Element label="E-mail" name="email" type="email" required />
    <Form.Submit />
  </Form>,
  container,
);

Example 2

import React from 'react';
import { render } from 'react-dom';
import Form from 'react-basic-form';

render(
  <Form onSubmit={data => console.log(data)}>
    <Form.Element>
      {({ showErrorMessage, onChange }) => (
        <div>
          <input name="fullname" type="text" onChange={onChange} placeholder="Full Name" required />
          {showErrorMessage('fullname')}
        </div>
      )}
    </Form.Element>
    <Form.Submit>
      {({ isLoading }) => (
        <button type="submit" disabled={isLoading}>
          {isLoading ? 'Sending' : 'Send'}
        </button>
      )}
    </Form.Submit>
  </Form>,
  container,
);

Example 3

import React from 'react';
import { render } from 'react-dom';
import Form from 'react-basic-form';

render(
  <Form onSubmit={data => console.log(data)}>
    {({ showErrorMessage, onChange, isLoading }) => (
      <div>
        <div>
          <input name="fullname" type="text" onChange={onChange} placeholder="Full Name" required />
          {showErrorMessage('fullname')}
        </div>
        <button type="submit" disabled={isLoading}>
          Send
        </button>
      </div>
    )}
  </Form>,
  container,
);

Example 4

import React from 'react';
import { render } from 'react-dom';
import Form from 'react-basic-form';

render(
  <Form
    onSubmit={(data, submitState) => {
      submitState.start(); // isLoading true
      setTimeout(() => {
        console.log(data);
        submitState.end(); // form reset && isLoading = false
      }, 1000);
    }}
  >
    <Form.Element label="Full Name" name="fullname" required />
    <Form.Submit />
  </Form>,
  container,
);

API

Form props

| Name | Type | Default | Description | | ------------------- | --------------------------- | --------------------------- | ----------------------------------------------------------------------------------------------------- | | onSubmit | (values, submitState) => {} | | form submission handler | | validations | Object | {} | validation rules for each form field | | errorMessages | Object | {} | error messages for each form field | | defaultErrorMessage | string | 'This field is required.' | default error message for form fields without defined error message | | children | React.Node or function | | if children is a function, this function should return the JSX which contains the form and all inputs |

Form.Element props

| Name | Type | Default | Description | | -------- | --------------------------------------------- | ------- | ----------------------------------------------------------------------------------------------------- | | options | Array(string) or Array(shape({label, value})) | | if type prop includes select,radio or checkbox, this prop is required | | label | string | | if this prop is filled, Form.Element will create a label tag with this string | | children | React.Node or function | | if children is a function, this function should return the JSX which contains the form and all inputs |

Form.Submit props

| Name | Type | Default | Description | | ----------- | ---------------------- | ----------- | ----------------------------------------------------------------------------------------------------- | | text | string | 'Send' | button text of the form | | loadingText | string | 'Sending' | button text of the form when submit state is loading | | children | React.Node or function | | if children is a function, this function should return the JSX which contains the form and all inputs |

children function arguments

| Name | Type | Description | | ---------------- | -------- | ------------------------------------------------------------------------ | | showErrorMessage | function | it takes form name as an argument and shows error message for this field | | onChange | function | function that controls validation errors on field value change | | isLoading | boolean | show submit state condition whether it's loading or not |

Development

npm install
npm start

Example

npm start and then go to http://localhost:3001/

License

react-basic-form is released under the MIT license.