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

react-free-forms

v1.0.10

Published

Component that will help you create form simple and easy way

Readme

REACT FREE FORMS 🌊🔥🔥🔥

React component that will make your forms quick and simple

Overview

React free forms is a React library that will help you implement form into your project easy and quick way. It has no DOM structure restrictions so you can create any form you like.

Suppoted input types:

  • text
  • number
  • password
  • select
  • radio
  • checkbox
  • email
  • tel

Instalation

npm i react-free-forms

How to use

First you have to import Form and Input Components.

import { Form, Input } from 'react-free-forms'

In all cases Form component should be wrapping all Input components you would like to be validated together. Basic structure looks like this:

<Form>
    <Input />
</Form>

Form component

Gathers all Input components and validates them by given rules. All props it can receive are optional.

| Prop Name | Prop Type | Description | | ------------------------- | ------------- | ------------------------- | | onSubmit | Function | Triggers upon successfully validated form with a result as a first argument | | onFailure | Function | Triggers upon failed validation while submitting a form | | onFocus | Function | Triggers when any form input is focused | | onBlur | Function | Triggers when any form input is blurred | | requiredErrorText | String | Passed as an error text for any required input that has no value | | className | String | Additional class for <form> tag rendered within this component | id | String | Additional id for <form> tag rendered within this component | | disabled | Boolean | Determines whether whole form should be disabled | | recaptcha | String | Receives ReCaptcha sitekey as its value. If present it will protect form submitting with ReCaptcha service and pass a ReCaptcha token in its result | | recaptchaInfoRef | Ref | This element will have its content replaced with obligatory information about recaptcha protection |

Input component

Renders <input> tag and decides about validation rules. Should be inserted inside <Form></Form> component. Only two props are required, others are optional.

| Prop Name | Prop Type | Description | | ----------------- | ------------- | ------------------------- | | required | Boolean | Required - tells whether input value is required | | name | String | Required - it will be a key of that input value in result object | | id | String | Custom id for <input> tag | | type | String | Supported types | | rule | String | Input Rules | | inputOptions | Array | Array of options for radio and select inputs | | inputClass | String | Custom class for <input> tag | | errorClass | String | Custom class for tag holding error | | labelClass | String | Custom class for <label> tag | | placeholder | String | Placeholder for input | | max | Number | Maximum value length (only for string values) | | min | Number | Minimum value length (only for string values) | | readonly | Boolean | Readonly attribute | | disabled | Boolean | Disable attribute | | onBlur | Function | Triggers when input is focused blurred | | onFocus | Function | Triggers when input is focused focused | | onBeforeChange | Function | Triggers when input value is about to be changed | | onAfterChange | Function | Triggers when input value has been changed | | title | String | Title block value above the input | | errorText | String | Custom error text when validation has failed | | group | String | Assigns this input value into given group inside result object | | minErrorText | String | Custom error text when value is too short | | requirederrortext | String | Custom error text for submitted required input with no value | | customRegex | String | Custom regex for validating input value | | defaultValue | String/Number | Input initial value |

Input rules

Rules define the way input should be validated. Most rules are self explanatory. For custom rule use customRegex prop.

  • text - any string
  • number - any number
  • select - any truhy
  • radio - any truhy
  • checkbox - checked
  • email
  • zip-code
  • phone
  • email
  • password - default password rule checks for:
    • a digit
    • a lowercase letter
    • an uppercase letter
    • at least 6 characters in total

Examples

Basic input example:

    <Form onSubmit={this.submitForm}>
        <Input name='text' required={true} />
    </Form>

Will render:

    <form>
        <label class="rff-inputComponent error" style="position: relative;">
            <input name="text" class="rff-inputComponent__input" value="">
            <p class="rff-inputComponent__error">input is required</p>
        </label>
    </form>

Radio and Select:

These types requires inputOptions prop that receives an array (or custom prop.children structure).

    <Form onSubmit={this.submitForm}>
        <Input name='radio' required={true} type='radio' inputOptions={[['test1', 'value1'], 'test2']} />
    </Form>

Will render:

<form>
    <label class="rff-inputComponent rff-inputComponent--radio" style="position: relative;">
        <div value="">
            <label>
                <input name="radio" type="radio" class="rff-inputComponent__input" value="value1">
                <span>test1</span>
            </label>
            <label>
                <input name="radio" type="radio" class="rff-inputComponent__input" value="test2">
                <span>test2</span>
            </label>
        </div>
    </label>
</form>

Custom Input children structure 😻

You are free to create your own structure inside Input component. When using Input component as a wrapper you can include only one <input>/<select> tag inside (or one set of radio inputs)

<Form onSubmit={this.submitForm}>
    <Input required={true} name='select' defaultValue='test2'>
        <select defaultValue='test2'>
            <option value='test'>test</option>
            <option value='test2'>test2</option>
        </select>
    </Input>
    <Input required={false} name='text'>
        <p>Input can even be wrapped another div</p>
        <div>
            <input type="text" />
        </div>
    </Input>
    <div>
        <div>
            <Input required={true} name='nested_input_component' />
        </div>
    </div>
    <button type='submit'>submit</button>
</Form>