React-Form
Simple, powerful, highly composable forms in React
live examples, code and docs!
Go toFeatures
- 🚀 Lightweight and fast.
- 🔥 Built-in input primitives for building quickly.
- ⚖️ Scales from tiny to massively complex forms with ease.
- 🚚 Easily integrate with 3rd party components or build your own!
- ✍️ Nested Fields and ultra-composable syntax for complex form shapes.
- ⏲ Asynchronous validation
- 🎛 Simple API that supports manipulating values, errors, warnings, and successes
- 👉 Render Props!
- 😂 Works in IE (with a polyfill or two)
Questions? Ideas? Chat with us!
Sign up for the React-Tools Slack Org!
Installation
npm install --save react-form
Basic Usage
; const ExampleForm = <Form render= submitForm <form onSubmit=submitForm> <Text field="firstName" placeholder='First Name' /> <Text field="lastName" placeholder='Last Name' /> <RadioGroup field="gender"> <Radio value="male" /> <Radio value="female" /> </RadioGroup> <TextArea field="bio" /> <Checkbox field="agreesToTerms" /> <button type="submit">Submit</button> </form> />
Array and Data-driven fields
; const ExampleForm = <Form render= <form onSubmit=submitForm> <Text field="firstName" placeholder="First Name" /> <Text field="lastName" placeholder="Last Name" /> <div> Friends valuesfriends && valuesfriends // Use the form api to add or remove values to the friends array <button type="button" onClick= >Add Friend</button> </div> <button type="submit">Submit</button> </form> />;
Advanced Field reuse, and Nested Fields
// Reuse The user fields for the user and their friends!const UserFields = <div> <Text field="firstName" placeholder="First Name" /> <Text field="lastName" placeholder="Last Name" /> </div> const ExampleForm = <Form onSubmit= console render= <form onSubmit=submitForm> <UserFields /> <NestedField field="friends" render= // Create a new nested field context <div> Friends valuesfriends && valuesfriends <button type="button" onClick= > Add Friend </button> </div> /> <button type="submit">Submit</button> </form> />
Examples & Documentation
Visit react-form.js.org for examples and documentation for 3.x.x of React-Form.
Older versions: