FormErrorSummary
Submit-time error list for forms of three or more fields (WCAG 3.3.1). A danger Callout whose heading takes focus after a failed submit, with a link per invalid field that focuses it.
// Plain markup
import { FormErrorSummary } from "@shavin/ui";After a failed submit
Press Save with the form empty: focus moves to the summary heading, each item links to its field, and every field keeps its own error.
Component Source
<form noValidate onSubmit={onSubmit}>
{errors.length > 0 && <FormErrorSummary key={attempt} errors={errors} />}
<TextField id="email" label="Email" errorMessage={fieldErrors.email} />
<FormField id="bio" label="Bio" error={fieldErrors.bio}><TextArea /></FormField>
<Button type="submit" loading={saving}>Save profile</Button>
</form>Accessibility
- The summary is a group named by its heading, not an alert: the focus move to the heading is the one announcement.
- Per-field error announcements are silenced for that render, so nothing is read twice.
- Remount it on each failed submit (a new key) so focus moves again.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| errors* | FormErrorSummaryItem[] | — | One entry per invalid field; each becomes a link that focuses that field. |
| title | string | Fix | Heading. Default "Fix 1 field to continue" / "Fix N fields to continue". |
| focusOnMount | boolean | true | Move focus to the heading when the summary appears after a failed submit (WCAG 3.3.1). Default true. |
| titleAs | "h2" | "h3" | "h4" | h2 | Heading element. Default h2. |
* required