GDS Error Banner Not Showing? Fix the Error Summary
In this article
The GDS error banner (the GOV.UK error summary that says "There is a problem") appears only when your template renders the error summary component and the page has at least one error in its error object. Most cases are fixed by adding the macro, passing errors in, and moving focus to it on validation failure.
Time 15 min · Steps 6 · Level Medium
Make the Error Summary Banner Appear in Six Steps
- Render the component. Add the
govukErrorSummarymacro (Nunjucks) or the error summary component (React/other ports) near the top of the page, before the main form content, so it is the first thing a screen reader or keyboard user reaches. - Pass the errors in. Give the macro an
errorListarray where each item hashref(the id of the field with the error, including the #) andtext(the error message). An empty or malformed array renders nothing. - Set the title text. The default heading is "There is a problem". Keep it unless your service has a reason to change it; the heading level should match the surrounding page structure.
- Move focus to the banner. On the server-side or client-side validation failure, set focus to the error summary container (it has
tabindex="-1"by default) so keyboard and screen reader users land on it immediately. - Link each item to its field. Each
hrefmust point to an element id that exists on the page, normally the erroring input or its error message container, so the link jumps the user to the problem. - Add per-field error messages. Each invalid input also needs the red error message and the
govuk-form-group--errorclass, plusaria-describedbypointing at the message id, so the banner and the field agree.
Symptom, Likely Cause and Fix at a Glance
Most "missing banner" reports come down to one of six things. Match what you see to the row and apply the fix.
| Symptom | Likely cause | Fix |
|---|---|---|
| No banner at all, fields show red errors | Error summary macro not rendered, or errorList empty | Add the macro above the form and build the array from your validation errors |
| Banner appears but links do nothing | href missing the field id or pointing at an id that does not exist | Set href to the exact id of the erroring input, including the leading # |
| Banner appears below the form or in a odd spot | Macro placed inside the form or main content block | Move it to the top of the page, after the back link and before the h1 or form |
| Focus stays on the first field | Nothing moves focus after validation fails | Set focus to the error summary on render when errors exist |
| Banner shows but fields are not marked invalid | Per-field error message and classes missing | Add the error message, the group error class and aria-describedby |
| Banner flashes then disappears | Client-side script re-rendering the page without errors | Keep the error state in the re-render, or re-trigger the summary after failed client validation |