@webiny/form
v5.41.2
Published
A simple React library for working with forms.
Downloads
5,398
Readme
@webiny/form
A simple React library for creating forms.
Install
npm install --save @webiny/form
Or if you prefer yarn:
yarn add @webiny/form
Quick Example
import React, { useCallback } from "react";
import { Form } from "@webiny/form";
import { Input } from "@webiny/ui/Input";
import { ButtonPrimary } from "@webiny/ui/Button";
import { validation } from "@webiny/validation";
const CarManufacturersForm = () => {
const onSubmit = useCallback(formData => console.log(formData), []);
return (
<Form data={{ title: "Untitled" }} onSubmit={onSubmit}>
{({ form, Bind }) => (
<React.Fragment>
<Bind name="title" validators={validation.create("required")}>
<Input label={"Title"} />
</Bind>
<Bind name="description" validators={validation.create("maxLength:500")}>
<Input
label={"Description"}
description={"Provide a short description here."}
rows={4}
/>
</Bind>
<ButtonPrimary onClick={form.submit}>Submit</ButtonPrimary>
</React.Fragment>
)}
</Form>
);
};
export default CarManufacturersForm;