@webiny/form
TypeScript icon, indicating that this package has built-in type declarations

5.40.1 • Public • Published

@webiny/form

code style: prettier PRs Welcome

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;

Readme

Keywords

none

Package Sidebar

Install

npm i @webiny/form

Weekly Downloads

1,050

Version

5.40.1

License

MIT

Unpacked Size

129 kB

Total Files

45

Last publish

Collaborators

  • webiny