# formsy-react [](https://github.com/christianalfoni/formsy-react/releases) [](https://travis-ci.org/christianalfoni/formsy-react) A form input builder and validator for React. | [Quick Start](#quick-start) | [API](/API.md) | [Examples](/examples) | | --------------------------- | -------------- | --------------------- | ## Background I wrote an article on forms and validation with React, [Nailing that validation with React JS](http://christianalfoni.github.io/javascript/2014/10/22/nailing-that-validation-with-reactjs.html), the result of that was this component. The main concept is that forms, inputs, and validation are done very differently across developers and projects. This React component aims to be that “sweet spot” between flexibility and reusability. ## What You Can Do 1. Build any kind of form element components. Not just traditional inputs, but anything you want, and get that validation for free 2. Add validation rules and use them with simple syntax 3. Use handlers for different states of your form. (`onError`, `onSubmit`, `onValid`, etc.) 4. Pass external errors to the form to invalidate elements (E.g. a response from a server) 5. Dynamically add form elements to your form and they will register/unregister to the form ## Install `yarn add formsy-react react react-dom` and use with webpack, browserify, etc. ## Quick Start ### 1. Build a Formsy element ```jsx // MyInput.js import { withFormsy } from 'formsy-react'; import React from 'react'; class MyInput extends React.Component { constructor(props) { super(props); this.changeValue = this.changeValue.bind(this); } changeValue(event) { // setValue() will set the value of the component, which in // turn will validate it and the rest of the form // Important: Don't skip this step. This pattern is required // for Formsy to work. this.props.setValue(event.currentTarget.value); } render() { // An error message is returned only if the component is invalid const errorMessage = this.props.getErrorMessage(); return (