Skip to content

Error Summary

Form InfrastructureSince 0.2.0

Accessible error navigation. ErrorSummary lists every error after a failed submission as links that move focus to the offending field, following the GOV.UK error summary pattern. The summary is a labelled region that receives focus when shown, so screen readers announce its heading and contents once, without a live region. Form creates and fills one automatically; it can also be used on its own, for example for server-rendered errors.

  • Linked errorsLists every error as a link that moves focus to the field that needs fixing.
  • Announced onceA labelled region that takes focus when shown, so screen readers read it once without a live region.
  • Custom focusItems can supply their own focus behavior, such as a component's focus method.
  • Standalone or automaticForm fills it for you, and it also works alone for server-rendered errors.

Use it for

  • After a failed form submission, to list all errors at the top of the form with links to each field.
  • Showing server-side errors after a full page load, including errors that belong to no field.

Use something else for

  • Inline messages next to a field: controls render those; for other controls use Validation Message.
  • Non-error notices or confirmations: use an alert or toast.
  • Forms managed by Form: it creates and fills the summary itself (use Form’s summaryHost to place it).
Anatomy
<div class="aui-error-summary" role="region" aria-labelledby=title tabindex="-1" hidden> (consumer host)
<h2 class="aui-error-summary__title" id=title>
<svg class="aui-error-summary__icon aui-icon" aria-hidden="true"><span>There is a problem</span>
</h2>
<p class="aui-error-summary__description"> (optional)
<ul class="aui-error-summary__list">
<li><a class="aui-error-summary__link" href="#field-id">Message</a></li> (item with target)
<li>Message</li> (item without target)
</ul>
</div>

Use the bar above each frame to switch theme, density, direction, and locale.

Error Summary in the Employee profile form showcase

Section titled “Error Summary in the Employee profile form showcase”

The part of the Employee profile form showcase that uses Error Summary. Change its options, use it with the keyboard, and watch the event log; the link in the frame opens the full showcase. The bar above the frame switches theme, density, direction, and locale.

Showcase source
// Forms showcase: an employee profile form that uses every form control together,
// with constraint validation, a cross-field rule, the error summary, reset, and live options.
import { Button } from '@absoluteui/components/button';
import { Checkbox } from '@absoluteui/components/checkbox';
import { CheckboxGroup } from '@absoluteui/components/checkbox-group';
import { Combobox } from '@absoluteui/components/combobox';
import { Fieldset } from '@absoluteui/components/fieldset';
import { Form, type FormSubmitDetail } from '@absoluteui/components/form';
import { FormField } from '@absoluteui/components/form-field';
import { MultiSelect } from '@absoluteui/components/multi-select';
import { NumberInput } from '@absoluteui/components/number-input';
import { RadioGroup } from '@absoluteui/components/radio-group';
import { Select } from '@absoluteui/components/select';
import { Slider } from '@absoluteui/components/slider';
import { Switch } from '@absoluteui/components/switch';
import { TextInput } from '@absoluteui/components/text-input';
import { Textarea } from '@absoluteui/components/textarea';
import { ValidationMessage } from '@absoluteui/components/validation-message';
import { action, annotate, choice, createShowcase, hostIn, toggle } from './kit.js';
const sc = createShowcase({
title: 'Employee profile',
description: 'Every form control in one form: required fields, formats, ranges, a cross-field rule, and an error summary on submit.',
});
const form = document.createElement('form');
form.className = 'sc-form';
form.noValidate = true;
sc.stage.append(form);
// Each fieldset declares its controls, so a component's focus view shows its own group.
const fieldset = (legend: string, description?: string): HTMLFieldSetElement => {
const fs = document.createElement('fieldset');
form.append(fs);
Fieldset.enhance(fs, { legend, ...(description ? { description } : {}) });
return fs;
};
const DEPARTMENTS = [
{ value: 'eng', label: 'Engineering' },
{ value: 'fin', label: 'Finance' },
{ value: 'hr', label: 'People' },
{ value: 'ops', label: 'Operations' },
{ value: 'sales', label: 'Sales' },
];
const MANAGERS = ['Ada Kowalski', 'Bruno Silva', 'Chen Wei', 'Divya Nair', 'Emeka Obi', 'Farah Haddad', 'Grace Liu', 'Hiro Tanaka'].map((name) => ({ value: name.toLowerCase().replace(/\s+/g, '-'), label: name }));
const SKILLS = ['Accessibility', 'Angular', 'Data analysis', 'Design systems', 'Finance', 'Negotiation', 'People management', 'TypeScript'].map((s) => ({ value: s.toLowerCase().replace(/\s+/g, '-'), label: s }));
// Personal details.
const personal = annotate(fieldset('Personal details'), ['form', 'error-summary', 'fieldset', 'text-input', 'textarea', 'form-field']);
const name = TextInput.create(hostIn(personal), { label: 'Full name', name: 'name', required: true, minLength: 2, autocomplete: 'name' });
const email = TextInput.create(hostIn(personal), { label: 'Work email', name: 'email', type: 'email', required: true, autocomplete: 'email', description: 'Used for sign-in and notifications.' });
const phone = TextInput.create(hostIn(personal), { label: 'Phone', name: 'phone', type: 'tel', inputMode: 'tel', pattern: '[+]?[0-9 ]{7,20}', description: 'Digits and spaces, with an optional leading +.' });
const bio = Textarea.create(hostIn(personal), { label: 'About', name: 'bio', maxLength: 280, showCounter: true, rows: 3, resize: 'vertical' });
// A native control labelled and validated by Form Field.
const badge = document.createElement('input');
badge.name = 'badge';
badge.inputMode = 'numeric';
badge.pattern = '[0-9]{6}';
FormField.create(hostIn(personal), { label: 'Badge number', control: badge, description: 'Six digits printed on your badge.' });
// Role.
const role = annotate(fieldset('Role'), ['form', 'error-summary', 'validation-message', 'fieldset', 'select', 'combobox', 'radio-group', 'number-input', 'slider', 'multi-select']);
const department = Select.create(hostIn(role), { label: 'Department', name: 'department', options: DEPARTMENTS, placeholder: 'Choose a department', required: true });
const manager = Combobox.create(hostIn(role), { label: 'Manager', name: 'manager', options: MANAGERS, placeholder: 'Type a name', description: 'Search by first or last name.' });
const type = RadioGroup.create(hostIn(role), { label: 'Employment type', name: 'type', orientation: 'horizontal', required: true, options: [{ value: 'full', label: 'Full time' }, { value: 'part', label: 'Part time' }, { value: 'contract', label: 'Contractor' }] });
const salary = NumberInput.create(hostIn(role), { label: 'Annual salary', name: 'salary', min: 10000, max: 500000, step: 1000, format: { style: 'currency', currency: 'EUR', maximumFractionDigits: 0 } });
const hours = Slider.create(hostIn(role), { label: 'Weekly hours', name: 'hours', min: 8, max: 48, step: 1, largeStep: 4, value: 40, marks: [{ value: 20, label: '20' }, { value: 40, label: '40' }], showValue: true });
const skills = MultiSelect.create(hostIn(role), { label: 'Skills', name: 'skills', options: SKILLS, maxSelected: 5, description: 'Up to five.' });
// Preferences.
const prefs = annotate(fieldset('Preferences', 'You can change these later in settings.'), ['form', 'error-summary', 'fieldset', 'checkbox-group', 'switch', 'checkbox']);
const benefits = CheckboxGroup.create(hostIn(prefs), { label: 'Benefits', name: 'benefits', orientation: 'horizontal', options: [{ value: 'health', label: 'Health' }, { value: 'pension', label: 'Pension' }, { value: 'transit', label: 'Transit pass' }, { value: 'gym', label: 'Gym' }] });
const remote = Switch.create(hostIn(prefs), { label: 'Works remotely', name: 'remote' });
const terms = Checkbox.create(hostIn(prefs), { label: 'I confirm these details are correct', name: 'terms', required: true });
// A standalone validation message for a rule that is not tied to one control.
const actions = annotate(hostIn(form), ['form', 'error-summary', 'validation-message']);
actions.className = 'sc-form__actions';
const hint = ValidationMessage.create(hostIn(actions), { tone: 'info', message: 'Part-time employees work at most 32 hours per week.' });
const buttons = hostIn(actions);
buttons.className = 'sc-form__buttons';
const submit = Button.create({ text: 'Save profile', variant: 'primary', type: 'submit' }, document);
const reset = Button.create({ text: 'Reset', variant: 'secondary', type: 'reset' }, document);
buttons.append(submit.element, reset.element);
const formController = Form.create(form, {
summaryTitle: 'Fix these fields to save the profile',
rules: [
{
fields: ['type', 'hours'],
validate: (values) => (values.type === 'part' && Number(values.hours) > 32 ? 'Part-time employees work at most 32 hours per week.' : null),
},
],
});
form.addEventListener('aui-submit', (e) => {
const { values } = (e as CustomEvent<FormSubmitDetail>).detail;
submit.setLoading(true);
// A save takes a moment; the button stays busy and focusable meanwhile.
setTimeout(() => {
submit.setLoading(false);
hint.update({ tone: 'success', message: `Saved the profile of ${typeof values.name === 'string' ? values.name : 'the employee'}.` });
}, 600);
});
form.addEventListener('aui-reset', () => {
hint.update({ tone: 'info', message: 'Part-time employees work at most 32 hours per week.' });
});
sc.listen(form, ['aui-submit', 'aui-invalid', 'aui-reset'], 'form');
for (const [label, host] of [
['name', name.host],
['email', email.host],
['department', department.host],
['manager', manager.host],
['type', type.host],
['salary', salary.host],
['hours', hours.host],
['skills', skills.host],
['benefits', benefits.host],
['remote', remote.host],
['terms', terms.host],
] as const) {
sc.listen(host, ['aui-change'], label);
}
// Options.
const all = [name, email, phone, bio, department, manager, type, salary, hours, skills, benefits, remote, terms];
toggle(sc, 'Disabled', false, (disabled) => {
for (const c of all) c.update({ disabled });
badge.disabled = disabled;
submit.update({ disabled });
});
toggle(sc, 'Read-only', false, (readOnly) => {
for (const c of [name, email, phone, bio, department, manager, salary, skills]) c.update({ readOnly });
badge.readOnly = readOnly;
});
choice(
sc,
'Validate',
[
{ value: 'blur', label: 'When leaving a field' },
{ value: 'input', label: 'While typing' },
{ value: 'submit', label: 'On submit only' },
],
'blur',
(timing) => {
for (const c of [name, email, phone, bio, department, type, salary, benefits, terms]) c.update({ validationTiming: timing });
},
);
action(sc, 'Fill sample data', () => {
name.setValue('Ada Lovelace');
email.setValue('ada@example.com');
phone.setValue('+44 20 7946 0000');
bio.setValue('Writes the first programs and reviews every pull request.');
badge.value = '204816';
department.setValue('eng');
manager.setValue('chen-wei');
type.setValue('full');
salary.setValue(86000);
hours.setValue(38);
skills.setValue(['typescript', 'accessibility']);
benefits.setValue(['health', 'pension']);
remote.setChecked(true);
terms.setChecked(true);
sc.log('sample data filled');
});
action(sc, 'Submit empty', () => {
formController.reset();
formController.submit();
}, ['form', 'error-summary']);

Standalone summary linking to invalid fields

Section titled “Standalone summary linking to invalid fields”
import { ErrorSummary } from '@absoluteui/components/error-summary';
import { TextInput } from '@absoluteui/components/text-input';
const summaryHost = document.createElement('div');
const nameHost = document.createElement('div');
document.body.append(summaryHost, nameHost);
const name = TextInput.create(nameHost, { label: 'Full name' }).input;
const summary = ErrorSummary.create(summaryHost);
// Focus moves to the summary; each linked item focuses its target on activation.
summary.show([
{ message: 'Enter your full name', target: name },
{ message: 'The service is busy. Try again in a few minutes.' },
]);

Summary for AbsoluteUI controls with a custom focus callback

Section titled “Summary for AbsoluteUI controls with a custom focus callback”
import { ErrorSummary, type ErrorSummaryNavigateDetail } from '@absoluteui/components/error-summary';
import { TextInput } from '@absoluteui/components/text-input';
const summaryHost = document.createElement('div');
const emailHost = document.createElement('div');
document.body.append(summaryHost, emailHost);
const email = TextInput.create(emailHost, { label: 'Email', name: 'email', type: 'email', required: true });
const summary = ErrorSummary.create(summaryHost, { headingLevel: 3, description: 'Fix the following to continue.' });
if (!email.reportValidity()) {
summary.show([{ message: email.validity.message, target: email.host, focus: () => { email.focus(); } }]);
}
summaryHost.addEventListener('aui-navigate', (event) => {
const { index } = (event as CustomEvent<ErrorSummaryNavigateDetail>).detail;
summaryHost.dataset.lastNavigated = String(index);
});

Heading level for pages whose form sits under an h2 (Mode B)

Section titled “Heading level for pages whose form sits under an h2 (Mode B)”
import { configureAbsoluteUI } from '@absoluteui/core';
import '@absoluteui/components/error-summary';
configureAbsoluteUI({ components: { errorSummary: { headingLevel: 3 } } });
Terminal window
npm install @absoluteui/components @absoluteui/core @absoluteui/theme

Registry setup, the theme stylesheet, and the Content Security Policy are covered in Installation.

import { ErrorSummary } from '@absoluteui/components/error-summary';
import '@absoluteui/components/error-summary/style.css';
import { ErrorSummary } from '@absoluteui/components/error-summary';
import '@absoluteui/components/error-summary/style.css';
// Errors rendered by the server into data attributes on each invalid input.
const host = document.querySelector<HTMLElement>('#error-summary');
if (host) {
const invalid = Array.from(document.querySelectorAll<HTMLInputElement>('input[data-error]'));
const summary = ErrorSummary.create(host);
summary.show(invalid.map((input) => ({ message: input.dataset.error ?? '', target: input })).filter((item) => item.message !== ''));
}
More usage
import { ErrorSummary } from '@absoluteui/components/error-summary';
const summaryHost = document.createElement('div');
const name = document.createElement('input');
name.id = 'full-name';
document.body.append(summaryHost, name);
ErrorSummary.create(summaryHost).show([{ message: 'Enter your full name', target: name }]);

Using Angular? See Error Summary for Angular.

ErrorSummary.create(host: HTMLElement, options?: ErrorSummaryOptions): ErrorSummary

Global configuration key: errorSummary (see Configuration).

Option Type Default Description
title string Heading text. Default: localized “There is a problem”.
description string Optional text under the heading.
icons Partial<{ error: IconRef }> Heading icon override.
headingLevel 2 | 3 | 4 2 Native heading element level. Globally configurable.
focusOnShow boolean true Move focus to the summary when show() displays items. show(items, { focus }) overrides it per call. Globally configurable.
locale string "en-US" Locale of the default heading. Globally configurable. Inherited from common configuration.
Property Type Description
host HTMLElement Consumer host; becomes the summary region.
items readonly ErrorSummaryItem[] Items currently shown.
isVisible boolean True while items are shown.
Method Description
show(items: readonly ErrorSummaryItem[], options?: { focus?: boolean }): void Replace the items and show the summary (an empty list hides it). Focuses and scrolls to the summary unless focus is false or focusOnShow is false. Throws on an empty message before changing anything.
clear(): void Remove all items and hide the summary without moving focus.
update(options: Partial<ErrorSummaryOptions>): void Merge options and re-render the heading and description. Invalid options leave the previous options in place.
destroy(): void Remove rendering, attributes, class, and the configuration subscription; unhide the host.
Event Detail Bubbles Cancelable Description
aui-navigate { index: number; message: string } Yes No A summary link was activated and focus moved to its target.

All rules live in the aui.components cascade layer, so application styles override them without specificity battles.

Class Purpose
aui-error-summary Host (role=region, tabindex=-1).
aui-error-summary__title Heading (h2, h3, or h4).
aui-error-summary__icon Heading icon.
aui-error-summary__description Optional text under the heading.
aui-error-summary__list List of errors.
aui-error-summary__link Link to a field; items without a target are plain list text.
Slot Default icon
error alert-circle

Tokens this stylesheet reads (verified in CI). Override them in a theme or with the Theme Designer.

--aui-border-width | --aui-border-width-strong | --aui-color-error-fg | --aui-color-error-subtle | --aui-color-focus-ring | --aui-color-text | --aui-focus-ring-offset | --aui-focus-ring-width | --aui-font-family-sans | --aui-font-size-md | --aui-font-weight-medium | --aui-font-weight-semibold | --aui-icon-size-md | --aui-line-height-normal | --aui-line-height-tight | --aui-radius-md | --aui-space-1 | --aui-space-2 | --aui-space-4 | --aui-space-5

TypeScript definitions
type HeadingLevel = 2 | 3 | 4;
interface ErrorSummaryItem { readonly message: string; readonly target?: HTMLElement | null; readonly focus?: () => void }
interface ErrorSummaryIcons { error: IconRef }
interface ErrorSummaryOptions { title?: string; description?: string; headingLevel?: HeadingLevel; focusOnShow?: boolean; locale?: string; icons?: Partial<ErrorSummaryIcons> }
interface ErrorSummaryNavigateDetail { index: number; message: string }

Pattern: GOV.UK error summary: a focusable, labelled region with a native heading and a list of in-page links to the invalid fields.

Checked on every docs build: the showcase passes axe (WCAG 2.2 A and AA rules) in the default, dark, and high-contrast themes and right to left; the playground loads without errors and passes axe before and after every on/off option is switched, with no Content Security Policy violations.

Key Context Action
Tab / Shift+Tab Summary or a link focused Moves between the summary links and the rest of the page.
Enter Link focused Focuses the target (or calls its focus callback), scrolls it to the center, and emits aui-navigate.
Element Role
host region
heading heading (native h2, h3, or h4)
list list (native ul)
item with target link (native a href=#id)
icon none (aria-hidden=true)
Attribute Element Value
aria-labelledby host Heading id
tabindex host -1, so the summary can receive programmatic focus without entering the Tab order

show() moves focus to the summary and scrolls it into view (focusOnShow). The host shows the shared focus ring on :focus-visible; links have their own 1px-offset focus ring.

Criterion Level Note
1.3.1 Info and Relationships A
1.4.1 Use of Color A
1.4.3 Contrast (Minimum) AA
2.1.1 Keyboard A
2.4.3 Focus Order A
2.4.6 Headings and Labels AA
2.4.7 Focus Visible AA
3.3.1 Error Identification A
3.3.3 Error Suggestion AA
4.1.2 Name, Role, Value A

Automated test results: Accessibility and compliance.

  • Focusing the summary makes screen readers announce the region name (the heading) and its contents once; no live region is used.
  • Link activation prevents the fragment navigation, so the URL hash does not change and focus lands on the control, not its container.
  • Links are underlined and error-colored; color is not the only cue.
  • Choose headingLevel to fit the page’s heading outline.
  • Announcement on focus has not yet been manually verified with NVDA, JAWS, and VoiceOver.
Import cost Minified gzip brotli CSS brotli
@absoluteui/components/error-summary 32.4 kB 11.4 kB 10.1 kB 0.5 kB

Measured at build time, including every AbsoluteUI module the component pulls in. No third-party runtime dependencies.

Budget (enforced in CI) Limit
ErrorSummary.show No dedicated performance test; renders one list item per error

Tested scale: Unit tests cover summaries with up to four items.

One configuration subscription and one click listener per link. show() rebuilds the list. No dedicated performance budget.

Measured run times: Performance.

States

hidden, visible, focused (:focus-visible ring), link hover (thicker underline), link focus-visible.

State transitions
From Trigger To
hidden show(items) with items visible; focused unless disabled
visible show(items) items replaced; focused again unless disabled
visible show([]) or clear() hidden; focus unchanged
visible link activated focus on target; aui-navigate
Accessibility notes
  • Focus moves to the summary when shown, so its name and contents are read once; no live region is used.
  • Link activation prevents the fragment navigation: the URL hash does not change and focus lands on the control itself.
  • Links are underlined and error-colored; color is not the only cue (WCAG 1.4.1).
  • Choose headingLevel to fit the page’s heading outline.
  • Manual screen-reader verification is pending (see Known limitations).
Responsive behavior

Block-level grid filling its container; long messages wrap.

Right-to-left

Logical properties: the thick border sits on the inline-start side and the list indents from the inline start.

Theming

Error-subtle background with error-foreground border, heading, and links, from role tokens only. Forced-colors mode uses CanvasText for the border and LinkText for links.

Global configuration
configureAbsoluteUI({ components: { errorSummary: { headingLevel: 3 } } });

Changes apply to existing instances immediately. Form passes focus explicitly (from its focusOnInvalid option), so focusOnShow does not affect Form-owned summaries.

Component configuration

Instance options override global and theme defaults. All options are dynamic.

Icons

icons.error (default alert-circle), shown in the heading.

Security

Heading, description, and messages use textContent and are never parsed as HTML. Link hrefs are only #id fragments of the targets. CSP-safe.

Data handling

No persistence, network access, or telemetry.

Supported data scale

Unit tests cover up to four items. A summary is meant for the errors of one form; dozens of items render without issue but become hard to use.

Edge cases
  • An item with an empty or non-string message throws ERROR_SUMMARY_ITEM before anything changes.
  • A target without an id receives a generated one.
  • show([]) hides the summary and never moves focus.
  • Calling show() again while visible re-focuses the summary (unless focus: false).
Errors
Code Category Cause
ERROR_SUMMARY_ITEM configuration An item’s message is empty or not a string.
CFG_INVALID_VALUE configuration headingLevel is not 2, 3, or 4, or focusOnShow is not a boolean.

Invalid options at construction throw before rendering; in update() they leave the previous options in place.

Known limitations
  • A target without an id is modified (an id is generated).
  • Without script, the #id link only scrolls; focus lands on the target only if it is focusable.
  • Heading levels are limited to 2, 3, and 4.
  • Announcement on focus has not yet been manually verified with NVDA, JAWS, and VoiceOver.
Unsupported scenarios
  • HTML or custom content in items.
  • Item actions other than navigation.