Skip to main content

Components

ErrorSummary

ErrorSummary is a summary of errors. It provides the user with an overview of errors or issues that need to be addressed on a page or step in order to proceed.

asChild
Type
any
NameTypeDefaultDescription
asChildany-

-

Usage

ErrorSummary consists of several subcomponents:

  • ErrorSummary.Heading defines the heading.
  • ErrorSummary.List defines the list of errors.
  • Each error is represented as an ErrorSummary.Item containing an ErrorSummary.Link.
  • Each ErrorSummary.Link must have an href to the unique identifier for a form field, so that the user can navigate to the correct place in the form.

Examples

Use with text fields

In order for ErrorSummary.Link to navigate to the fields with errors, the fields must have a unique id that matches the href in the link.

Moving focus

Below is an example where we move focus to ErrorSummary when it becomes visible.

HTML

The class name ds-error-summary is used on a container, the default for React is <div>.

As a child, you must have a heading (preferably <h2>) that has an id that can be referenced with aria-labelledby on the container.

We add a ds-list after the heading that contains a list of errors. Each error is a <li> with a link (<a>) that has the class ds-link and an href to the relevant field with errors.

CSS variables and data attributes

CSS Variables
NameValue
--dsc-errorsummary-backgroundvar(--ds-color-danger-surface-tinted)
--dsc-errorsummary-border-radiusvar(--ds-border-radius-md)
--dsc-errorsummary-paddingvar(--ds-size-6) var(--ds-size-8)
--dsc-errorsummary-link-colorvar(--ds-color-neutral-text-default)
--dsc-errorsummary-heading-colorvar(--ds-color-danger-text-default)

No relevant data attributes found.

Edit this page on github.com (opens in a new tab)