On this page
@addTagHelper *, Webority.Ui.RazorTry it
Press Save with an empty field to see the summary take focus and list every problem.
A form with two required fields
The server validates the submit and re-renders the values. Every field also shows its own message.
Basic
Use the default heading when the form only needs to say how many fields to fix.
Two errors, default title
The heading reads Fix 2 fields to continue. With one error it reads Fix 1 field to continue.
Fix 2 fields to continue
Custom title
Set a title when the form has its own wording, such as a save or a send.
A title that names the action
The list below it is unchanged.
Fix 2 fields to save
Every option
Every value of every prop, one cell each.
errors
errors: one error
Fix 1 field to continue
errors: three errors
title
title omitted (default): the heading counts the fields
Fix 2 fields to continue
title="Check these fields before you send"
Check these fields before you send
autoFocus
auto-focus (default true): takes focus when errors appear; off in this demo
Fix 2 fields to continue
id
id: names the summary, and its heading id is built from it
Fix 2 fields to continue
className
class="mb-0": adds a class to the summary element
Fix 2 fields to continue
from-model-state
from-model-state (default): lists only the items written inside
Fix 2 fields to continue
from-model-state="true": also lists the page's model errors
Guidance
What to do, and what to avoid.
Use it when
- A form with more than one field failed to submit, and the reader needs to see everything wrong at once.
- Keyboard and screen reader users should land on the list and reach each field from it.
- You also show each field's own error, so the list and the fields agree.
Reach for something else when
- You have one message that does not belong to a field. → AppAlert
- The feedback is brief, such as Saved or Copied. → toast
- The form has a single field. → that field's own error prop
Reference
Try every prop, read the full list, and check keyboard and screen reader behaviour.
7 props. The 2 most used come first.
Used on most screens 2 props
| Prop | Type | Default | Description |
|---|---|---|---|
| titledefault Fix N fields to continue | string | Fix N fields to continue | The heading. Defaults to Fix N fields to continue, or Fix 1 field to continue for one item. |
| auto-focusdefault true | bool | true | Take focus when errors appear. Turn off only where the summary is shown for reference, such as documentation, never on a form. |
Less common 5 props
| Prop | Type | Default | Description |
|---|---|---|---|
| iddefault generated | string | generated | DOM id of the summary; its heading id is built from it. |
| from-model-statedefault false | bool | false | Lists every error in the page's ModelState after the items written inside, so a form page needs no loop. Each error links to its field by name; a whole-form error (the empty key) links to nothing. |
| classdefault - | string | - | Extra classes merged onto the summary. |
| app-error-summary-item fielddefault - | string | - | On an app-error-summary-item child: the id or name of the input to focus. A custom field focuses its inner control. |
| app-error-summary-item contentdefault - | string | - | The element's text is the message and the link text. An empty item is left out. With no items the summary renders nothing. |
Screen reader
3 notes- The summary has role alert and takes focus when errors appear, so a screen reader announces the title and the count.
- Only the step from no errors to some errors takes focus, so a re-render while the user types a fix never pulls focus from the field.
- Each message is a link that moves focus to its field by id or name; the plain anchor stays as the no-script fallback.