A component to handle submitting forms.

Importing

The component can be imported via:

import { Form } from '@customerio/pluma-components/react';

Usage

The Form component is used to handle submitting forms. It is a drop-in replacement for the native <form> element, but with additional features.

<Form>
 <FormLayout>
   <TextField label="First name" />
   <TextField label="Last name" />
   <ButtonGroup>
    <Button type="submit">Submit</Button>
   </ButtonGroup>
  </FormLayout>
</Form>

Disabling a form

To disable a form, you can pass the isDisabled prop to the Form component.

<Form isDisabled>
  <FormLayout>
    <TextField label="First name" />
    <TextField label="Last name" />
    <ButtonGroup>
      <Button type="submit">Submit</Button>
    </ButtonGroup>
  </FormLayout>
</Form>

Autoloading

By default, autoLoading is true. This means the form will disable other submissions and edits while the form is submitting. You can disable this behavior by passing autoLoading={false} to the Form component.

import { Form, TextField, Button, FormLayout, ButtonGroup } from '@customerio/pluma-components/react';

export default function FormExample() {
  const handleSubmit = async () => {
    await new Promise((resolve) => setTimeout(resolve, 2000));
  };

  return (
    <Form onSubmit={handleSubmit}>
      <FormLayout>
        <TextField label="First name" />
        <TextField label="Last name" />
        <ButtonGroup>
          <Button type="submit">Submit</Button>
        </ButtonGroup>
      </FormLayout>
    </Form>
  );
}

API

PlumaForm extends Box

If true, the form will automatically lock the fields when the onSubmit function is called and it returns a promise.

Disables the form and all its fields.

The function to call when the form is submitted

On this page