Skip to content
Mosaic
On this page

Form

A <form> that never shows the browser's validation popup. It always sets noValidate, so controls keep required and type for assistive tech and keyboards while the caller owns validation.

Use for

  • a <form> element without the browser validation popup
  • every form in Mosaic, in place of a bare <form>

Practices

GuidancePractice
DoUse Form for every form. Lint flags a bare <form>.
DoWhen another part owns the node, pass it through that part's render, such as <Card.Content render={<Form id={formId} onSubmit={handleSubmit} />}>.
Don’tValidate in the view or call preventDefault by hand. Use useForm for values, validation and submit.

API reference

Form

Renders a form, or the render element, with noValidate always set. Forwards its ref.

Examples

A form

TSX
<Form onSubmit={form.handleSubmit}>…</Form>