Skip to content

Form

Native form with consolidated Field validation and optional server error maps.

Examples

Submit

Overview

Form wraps fields and calls onFormSubmit with values after validation. Pass errors for server-side messages keyed by Field name.

tsx

import { Form, Field, FieldLabel, FieldControl, Button } from "@standard-ui/react"

<Form onFormSubmit={(values) => { /* … */ }}>
  <Field name="email">
    <FieldLabel>Email</FieldLabel>
    <FieldControl type="email" required />
  </Field>
  <Button type="submit">Submit</Button>
</Form>

API

PropRole
validationModeonSubmit, onBlur, or onChange.
errorsExternal/server errors keyed by field name.
onFormSubmitCalled with values after client validation passes.

Guidelines

Do

  • Give every Field a stable name
  • Map server errors into the errors prop

Don't

  • Don't nest forms
  • Don't rely only on visual cues — keep FieldError text