Skip to content

ErrorSummary

The error list at the top of a long form after a failed POST. Each item links to its field.

FeedbackIsland

Examples

Two invalid fields

On a page it takes focus once; inside a dialog pass autoFocus={false} (the dialog focuses the first invalid field).

Enter the server URL, starting with https://

Header name can’t contain spaces

Example
<ErrorSummary errors={[
  { field: 'server-url', message: 'Enter the server URL, starting with https://' },
  { field: 'header-name', message: 'Header name can’t contain spaces' },
]} />

Usage

Usage
import { ErrorSummary } from '@switchboard/ui'

{errors.length ? <ErrorSummary errors={errors} /> : null}

Props

Every component also takes mix, for css() and mixins applied after its own style.

ErrorSummary

ErrorSummary props
PropTypeDefaultDescription
errors*{ field: string; message: string }[]–field is the control id. Renders nothing when empty.
titlestring'Fix N fields to continue'Heading.
autoFocusbooleantrueTake focus once after render. Off inside dialogs.

Accessibility

  • A focusable group (tabindex=-1) named by its heading; it takes focus once so screen readers read it first.
  • Links are real #id anchors (work without JS); with JS they also move focus into the field.
  • Repeat each message on its Field so it is announced again on the control.

Guidance

Do

  • Use it on long forms (server settings).
  • Use the same words as the field error.

Don’t

  • Use it for one-field forms; the Field error is enough.