Internal ID software / Forms
ErrorSummary
What a rejected form says first: every problem, each a link to its field.
Not drawn in Figma: built only from the tokens, for internal ID software. In code: components/software/form.tsx. From the old system: ErrorSummary in @id-identity-as/ui/form.
Example
Skriv en e-mailadresse
CVR-nummeret skal have otte cifre
Skriv en e-mailadresse
CVR-nummeret skal have otte cifre
import { ErrorSummary } from '@/components/software/form';
<ErrorSummary
title="Ret 2 felter"
errors={[
{ id: 'email', message: 'Skriv en e-mailadresse' },
{ id: 'cvr', message: 'CVR-nummeret skal have otte cifre' },
]}
/>Props
| Prop | Type | Default | What it does |
|---|---|---|---|
title (required) | string | The heading, such as "Ret 2 felter". Written by the page, so it can be translated and counted. | |
errors (required) | Array<{ id: string; message: string }> | One line per field: the id of the field and what to do. An empty list renders nothing. | |
id | string | 'error-summary' | A stable id, so the form can send focus here. |
Do
- Place it first in the form.
- Send focus to it when the form comes back with errors.
- Repeat each message on its field with the error prop.
Do not
- Do not use it for what the browser already validates before the form posts.
- Do not colour it red. The doubled edge marks it.
Accessibility
- role="alert", and it can take focus from script (tabindex -1).
- Every message is a link to its field, so one press moves there.
Tokens it uses
- color.text.default
- radius.sm
- type.heading.md
- type.body.md
- space.inline.2
- space.inline.3
- space.inline.5