react-standalone-form
Advanced tools
Create React forms just with a pure JSX and let the react-standalone-form manage its state for you.
Weekly downloads
Readme
This package in version 2.0 has been renamed and its development is now continued as react-form-component.
Create React forms just with a pure JSX and let the react-standalone-form manage its state for you. A themeable form library based on Context API with a selection of user friendly inputs and wide customization abilities to match your design and functionality.
yarn add react-standalone-form
<FormThemeProvider>
. Optionally define a custom theme in theme prop.<Form>
component anywhere in the app, declare all fields in a fields
prop array.name
prop that corresponds with a name defined in a fields
array of the ancestor <Form>
component.<FormButton>
to trigger a submit function that returns all field values formatted in a form of a simple javascript object.// App.js
import React from 'react'
import ReactDOM from 'react-dom'
import Form, {
FormThemeProvider,
Input,
Select,
FormButton,
} from 'react-standalone-form'
// Wrap entitre app into FormThemeProvider.
const App = () =>
<FormThemeProvider>
<div className='my-app'>
<BasicFormExample />
</div>
</FormThemeProvider>
// Build a fully operational form.
const BasicFormExample = () =>
<Form fields={['name', 'email', 'type']}>
<Input
name='name'
label='User name'
/>
<Input
name='email'
type='email'
label='E-mail'
/>
<Select
name='type'
label='Type of a user'
options={['Viewer', 'Moderator', 'Admin']}
/>
<FormButton
onClick={fields => console.log(fields)}
>Save</FormButton>
</Form>
ReactDOM.render(<App />, document.querySelector('#app'))