Skip to main content
Components

Error summary

Use an error summary when there is a validation error.

Children are ListItemComposites.

Read the Design System guidance for error summary

Import

import * as ErrorSummary from 'govuk-react/error-summary';

Examples

Default

Code
<ErrorSummary.Composite {...args} disableAutoFocus={viewMode === 'docs'} />

With field

The summary takes focus when it appears, and its link moves focus to the field, with its label in view.

Code
<>
  <ErrorSummary.Composite title="There is a problem" disableAutoFocus={viewMode === 'docs'}>
    <ErrorSummary.ListItemComposite href="#full-name">Enter your full name</ErrorSummary.ListItemComposite>
  </ErrorSummary.Composite>
  <InputField id="full-name" name="fullName" label="Full name" errorMessage="Enter your full name" />
</>

API reference

ErrorSummary.Root

Use an error summary when there is a validation error.

It takes focus when it appears. To move focus to it again, such as after another invalid submit, give it a new key.

PropType
disableAutoFocus

Prevent moving focus to the error summary when the page loads.

boolean

ErrorSummary.Alert

No props of its own. Other props are passed to the element it renders.

ErrorSummary.Body

No props of its own. Other props are passed to the element it renders.

ErrorSummary.Composite

Use an error summary when there is a validation error.

Children are ListItemComposites.

PropType
disableAutoFocus

Prevent moving focus to the error summary when the page loads.

boolean
titleRequired

The heading of the error summary block.

ReactNode
description

The description of the errors.

ReactNode
errors

Prefer children, which memoise and re-render better.

ListItemCompositeProps[]

ErrorSummary.Description

No props of its own. Other props are passed to the element it renders.

ErrorSummary.List

No props of its own. Other props are passed to the element it renders.

ErrorSummary.ListItem

No props of its own. Other props are passed to the element it renders.

ErrorSummary.ListItemComposite

Links to the field with the error when there's an href.

PropType
href

Href attribute for the error link item. If provided item will be an anchor.

string

The link to the field with the error.

No props of its own. Other props are passed to the element it renders.

ErrorSummary.Title

No props of its own. Other props are passed to the element it renders.