0.11.1 • Published 5 years ago
formin v0.11.1
formin
Primitive for building forms in react
I built formin to serve as a tiny (~1.5kb) alternative to other form solutions in react with these goals in mind
- Simple API
- Tiny size
- Work great with native HTML form validation
- Great a11y support
- Extendable
Install
$ npm install formin
You can also play around with it in CodeSandbox.io.
Usage
Hook
import { useFormin } from 'formin'
function Form() {
const { getInputProps, getFormProps } = useFormin({
onSubmit: ({ values }) => {
console.log(values)
},
})
return (
<form {...getFormProps()}>
<input {...getInputProps({ name: 'foo' })} />
<input {...getInputProps({ name: 'bar' })} />
<button>Submit</button>
</form>
)
}
Render prop
import { Formin } from 'formin'
function MyForm() {
return (
<Formin
onSubmit={({ values }) => {
console.log(values)
}}
>
{({ getFormProps, getInputProps }) => (
<form {...getFormProps()}>
<input {...getInputProps({ name: 'foo' })} />
<input {...getInputProps({ name: 'bar' })} />
<button>Submit</button>
</form>
)}
</Formin>
)
}
Docs
Other solutions
This library is heavily inspired by Formik but takes a different approach to the problem.
License
0.11.1
5 years ago
0.11.0
5 years ago
0.10.0
5 years ago
0.9.3
5 years ago
0.9.2
5 years ago
0.9.1
5 years ago
0.9.0
5 years ago
0.8.0
5 years ago
0.7.1
5 years ago
0.7.0
5 years ago
0.6.1
6 years ago
0.6.0
6 years ago
0.5.1
6 years ago
0.5.0
6 years ago
0.4.0
6 years ago
0.3.1
6 years ago
0.3.0
6 years ago
1.0.0
6 years ago
0.2.1
6 years ago
0.2.0
6 years ago
0.1.0
6 years ago
0.0.1
6 years ago