# react-form **Repository Path**: mirrors_clauderic/react-form ## Basic Information - **Project Name**: react-form - **Description**: A simple and powerful form builder for React - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-09-24 - **Last Updated**: 2026-05-23 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README
React Table Logo

[![Build Status](https://travis-ci.org/tannerlinsley/react-form.svg?branch=master)](https://travis-ci.org/tannerlinsley/react-form) [![npm](https://img.shields.io/npm/dm/react-form.svg)](https://npmjs.com/packag/react-form) [![react-form on Slack](https://img.shields.io/badge/slack-react--form-blue.svg)](https://react-table-slack.herokuapp.com/) [![GitHub stars](https://img.shields.io/github/stars/tannerlinsley/react-form.svg?style=social&label=Star)](https://github.com/tannerlinsley/react-form) [![Twitter Follow](https://img.shields.io/twitter/follow/tannerlinsley.svg?style=social&label=Follow)](https://twitter.com/tannerlinsley) React Form is a lightweight framework and utility for building powerful forms in React applications. ## Features - **4kb!** (minified) - Dynamic Fields - no pre-defined schema or field names required - Highly functional and flexible validation - Built-in Form Inputs - Input Utility - Easily and quickly build your own input types - Field Utility - Functionally control any field, anywhere in a form - Nested forms and form splitting - Powerful form lifecycle hooks and events - Serializable Event and State hooks (think redux/mobx/etc & HMR) ## [Demo](http://react-form.zabapps.com) ## Table of Contents - [Installation](#installation) - [Example](#example) - [Custom Input Example](#custom-input-example) - [API](#api) - [{ Form }](#-form-) - [Default Props & Form Lifecycle](#default-props--form-lifecycle) - [Form Component Props](#form-component-props) - [{ FormDefaultProps }](#-formdefaultprops-) - [{ FormInput }](#-forminput-) - [{ FormError }](#-formerror-) - [{ FormField }](#-formfield-) - [{ Text, Select, Checkbox, Textarea }](#-text-select-checkbox-textarea-) - [{ NestedForm }](#-nestedform-) ## Installation ```bash $ npm install react-form ``` ## Example Enjoy this annotated example demonstrating a majority of React-Table's features. ```javascript import React from 'react' import { Form, Text, Select, Textarea, NestedForm, FormError } from 'react-form' // To create a new form, simply call `Form(config)(component)` const MyForm = Form({ // This is our config for the form. Think of it as the default props for your Form :) // Let's give the form some hard-coded default values defaultValues: { friends: [] }, // Validating your form is super easy, just use the `validate` life-cycle method validate: values => { const { name, hobby, status, friends, address } = values return { name: !name ? 'A name is required' : undefined, hobby: (hobby && hobby.length < 5) ? 'Your hobby must be at least 5 characters long' : false, status: !status ? 'A status is required' : null, friends: (!friends || !friends.length) ? 'You need at least one friend!' : friends.map(friend => { const { name, relationship } = friend return { name: !name ? 'A name is required' : undefined, relationship: !relationship ? 'A relationship is required' : undefined } }), address: !address ? 'A valid address is required' : 0 } }, // `onValidationFail` is another handy form life-cycle method onValidationFail () { window.alert('There is something wrong with your form! Please check for any required values and try again :)') } })(({ values, submitForm, addValue, removeValue, getError }) => { // This is a stateless component, but you can use any valid react component to render your form. // Forms also supply plenty of useful props for your components to utilize. See the docs for a complete list. return ( // When the form is submitted, call the `sumbitForm` callback prop