getFormProps
A helper that returns all the props required to make a form element accessible.
1const props = getFormProps(form, options);#Example
1import { useForm, getFormProps } from '@conform-to/react';
2
3function Example() {
4  const [form, fields] = useForm();
5
6  return <form {...getFormProps(form)} />;
7}#Options
ariaAttributes
Decide whether to include aria-describedby in the result props. Default to true.
ariaInvalid
Decide whether the aria attributes should be based on meta.errors or meta.allErrors. Default to errors.
ariaDescribedBy
Append additional id to the aria-describedby attribute. You can pass meta.descriptionId from the field metadata.
#Tips
The helper is optional
The helper is just a convenience function to help reducing boilerplate and make it more readable. You can always use the form metadata directly to set the props of your form element.
1// Before
2function Example() {
3  return (
4    <form
5      id={form.id}
6      onSubmit={form.onSubmit}
7      noValidate={form.noValidate}
8      aria-describedby={!form.valid ? form.errorId : undefined}
9    />
10  );
11}
12
13// After
14function Example() {
15  return <form {...getFormProps(form)} />;
16}Make your own helper
The helper is designed for the native form elements. If you need to use a custom component, you can always make your own helpers.