Skip to content
Vertical Jump Designs-uiFront-End Studio
Get Pro

v3.9 is out.

Feedback

ErrorSummary

Free16.2 KB gzipped

The list of a form's errors, shown above it after a failed submit: a danger Alert whose items link to their fields (activating one moves focus to the field). It's focusable (tabIndex={-1}): give useFormValidation's summaryRef as ref and a failed submit moves focus here, so screen readers announce the heading and the list. The title is a real heading (h2 by default; set headingLevel to fit the page outline).

Accessibility: WCAG 2.2 AA · No A or AA violations in light or dark mode · Keys: Tab, Enter · Full report

Import

tsx
import { ErrorSummary } from "@vjdesigns/vjdesigns-ui";

Importing only ErrorSummary adds about 16.2 KB of minified, gzipped JavaScript to your app (React not included). The stylesheet is shared by every component and loaded once: 75.1 KB gzipped.

Examples

Basic

Each error links to its field: activating a link moves focus there. Give each Field the id the item points to (from useId, so two copies of the form never share ids). headingLevel fits the title into the page outline (here, under an h3).

Enter an email address, like name@example.com.

Use at least 8 characters.

tsx
import { useId } from "react";
import { ErrorSummary, Field, Input, Stack } from "@vjdesigns/vjdesigns-ui";

export function Basic() {
  const id = useId();
  const errors = [
    { name: "email", id: `${id}-email`, message: "Enter an email address, like name@example.com." },
    { name: "password", id: `${id}-password`, message: "Use at least 8 characters." },
  ];

  return (
    <Stack gap={4} style={{ width: "100%", maxWidth: "28rem" }}>
      <ErrorSummary errors={errors} headingLevel={4} />
      <Field id={errors[0].id} label="Email" error={errors[0].message}>
        <Input name="email" type="email" autoComplete="email" defaultValue="dan@" />
      </Field>
      <Field id={errors[1].id} label="Password" error={errors[1].message}>
        <Input name="password" type="password" autoComplete="new-password" defaultValue="short" />
      </Field>
    </Stack>
  );
}

With validation

With useFormValidation: pass errorList as errors and summaryRef as ref. Submit the empty form: focus moves to the summary, so screen readers announce its heading and list. Errors come from the browser's own checks (required, type="email", minLength) plus rules, in the current language, and clear as each field is fixed.

At least 8 characters.

tsx
import { useState } from "react";
import {
  Button,
  ErrorSummary,
  Field,
  Input,
  Stack,
  Text,
  rules,
  useFormValidation,
} from "@vjdesigns/vjdesigns-ui";

export function WithValidation() {
  const [sent, setSent] = useState(false);
  const form = useFormValidation({
    rules: { confirm: rules.matches("password") },
    onValid: () => setSent(true),
  });

  return (
    <form {...form.formProps} style={{ width: "100%", maxWidth: "28rem" }}>
      <Stack gap={4}>
        <ErrorSummary ref={form.summaryRef} errors={form.errorList} headingLevel={4} />
        <Field label="Email" required error={form.errors.email}>
          <Input name="email" type="email" autoComplete="email" />
        </Field>
        <Field label="Password" required hint="At least 8 characters." error={form.errors.password}>
          <Input name="password" type="password" minLength={8} autoComplete="new-password" />
        </Field>
        <Field label="Confirm password" required error={form.errors.confirm}>
          <Input name="confirm" type="password" autoComplete="new-password" />
        </Field>
        <Button type="submit">Create account</Button>
        <Text role="status">{sent ? "Account created." : ""}</Text>
      </Stack>
    </form>
  );
}

Server errors

Errors from the server: return them from onValid and they show on their fields and in the summary, and stay until the field is edited. Try any email ending in @example.com.

tsx
import {
  Button,
  ErrorSummary,
  Field,
  Input,
  Stack,
  useFormValidation,
} from "@vjdesigns/vjdesigns-ui";

export function ServerErrors() {
  const form = useFormValidation({
    onValid: async (values) => {
      await new Promise((resolve) => setTimeout(resolve, 600));
      if (String(values.email).endsWith("@example.com")) {
        return { email: "That email is already registered. Sign in instead, or use another one." };
      }
    },
  });

  return (
    <form {...form.formProps} style={{ width: "100%", maxWidth: "28rem" }}>
      <Stack gap={4}>
        <ErrorSummary ref={form.summaryRef} errors={form.errorList} headingLevel={4} />
        <Field label="Email" required error={form.errors.email}>
          <Input name="email" type="email" autoComplete="email" defaultValue="dan@example.com" />
        </Field>
        <Button type="submit" loading={form.isSubmitting}>
          Join the waitlist
        </Button>
      </Stack>
    </form>
  );
}

Right to left

The first example again, inside a right-to-left LocaleProvider (Arabic). Layout, spacing and arrow icons mirror, and the components' built-in text is translated. The example's own text stays in English.

Basic

Enter an email address, like name@example.com.

Use at least 8 characters.

tsx
import { LocaleProvider } from "@vjdesigns/vjdesigns-ui";
import ar from "@vjdesigns/vjdesigns-ui/locales/ar";

// Basic is the "Basic" example above.
<LocaleProvider locale="ar" messages={ar}>
  <Basic />
</LocaleProvider>

Usage notes

tsx
<ErrorSummary ref={form.summaryRef} errors={form.errorList} />

API reference

ErrorSummary

New in 1.4.10
ErrorSummary props
PropTypeDefault
errorsRequired

The errors, in page order: useFormValidation's errorList, or your own. Renders nothing when empty.

readonly ErrorSummaryItem[]—
title

Heading.

ReactNode"There is 1 problem" / "There are 3 problems", in the current language
variant

Surface style.

"soft""solid""outline""soft"
size

Padding, type size, and icon size.

"sm""md""lg""md"
radius

Corner rounding.

"none""xs""sm""md""lg""xl""2xl""pill""lg"
as

Root element. section and aside become labelled landmarks when there is a title.

"div""section""aside""div"
icon

Icon in the tinted circle. Defaults to a distinct shape per tone (info, success check, warning triangle, error). Pass false to hide it. Always decorative (hidden from assistive technology): the tone is also conveyed by toneLabel and the text.

ReactNode | false—
headingLevel

Renders the title as a real heading (h1-h6) at this level. Leave unset for a plain bold paragraph, which suits most inline alerts.

123456—
actions

Action row under the description, usually Buttons (size sm) or Links.

ReactNode—
toneLabel

Visually hidden prefix read before the title (or the description, when there is no title), e.g. "Error: ". true uses the default for the tone, a string sets your own (localize it here), false turns it off.

string | booleanon for `danger` ("Error: ") and `warning` ("Warning: "), off otherwise
dismissLabel

Accessible name of the dismiss button. Localize it here.

string"Dismiss"
returnFocusRef

Element to focus after dismissal, so keyboard focus isn't lost when the alert (and its dismiss button) disappears. Pick the control that triggered the alert, or the next logical element. If unset and focus was inside the alert, handle focus yourself in onDismiss.

RefObject<HTMLElement | null>—
open

Whether the alert is shown (controlled). Set with onOpenChange to control dismissal.

boolean—
defaultOpen

Whether the alert is shown initially (uncontrolled).

booleantrue
onOpenChange

Called with false when the alert is dismissed.

(open: boolean) => void—
live

Live-region behavior. See AlertLive.

"off""polite""assertive""off"

Also accepts standard HTML attributes, plus className, style and ref.

See what changed in each version in the Changelog.

Accessibility report

ErrorSummary targets WCAG 2.2 AA. Below: a live axe-core audit of this page's examples, Lighthouse scores for the page in both modes, the accessibility behavior built into the component, and the checks only a person can do.

axe-core audit (live)

Running accessibility audit

Checking the examples above…

Lighthouse audit

Light mode

Score 100

37 passed · 0 failed · 28 not applicable · 10 to check by hand

Dark mode

Score 100

37 passed · 0 failed · 28 not applicable · 10 to check by hand

Lighthouse 13.5.0 audits the whole docs page (header and sidebar included), not just the examples, in English. Last run 11/27/2026. Some failed audits carry no weight in the score, so a page can score 100 and still list one.

Built-in behavior

Keyboard

Keyboard
KeyAction
TabMoves through the error links, in the order of the fields.
EnterOn an error link: moves focus to that field (not just scrolling to it).

With useFormValidation's summaryRef, a failed submit moves focus to the summary (tabindex="-1"), so screen readers read its heading and list. Without it, focus goes to the first invalid field.

Roles and states

Roles and states
ElementRoleStates and properties
Summarynone (generic)tabindex="-1", so it can take focus; not a live region (focus moving to it announces it)
TitleheadingLevel from headingLevel (default 2); "There are 2 problems", in the current language
ErrorslistOne item per error
Errorlinkhref="#id" of the field's control; the text is the field's error message

Manual checks

Automated tools find roughly a third of accessibility issues. Test these in your app, with your content.

Manual accessibility checks
CheckWhat to testWCAG 2.2
KeyboardEvery action works with Tab, Shift+Tab, Enter, Space and the arrow keys, and focus never gets stuck.2.1.1 (A), 2.1.2 (A)
FocusFocus moves in a logical order, is always visible, and isn't hidden behind sticky headers.2.4.3 (A), 2.4.7 (AA), 2.4.11 (AA), 2.4.13 (AAA)
Screen readersNames, roles and states are announced correctly, and status changes are announced without moving focus.1.3.1 (A), 4.1.2 (A), 4.1.3 (AA)
ColorMeaning never depends on color alone; your own colors meet contrast in both modes.1.4.1 (A), 1.4.3 (AA), 1.4.11 (AA), 1.4.6 (AAA)
Zoom and reflowAt 200% text size and at 320px wide (400% zoom), nothing is cut off and no sideways scrolling is needed.1.4.4 (AA), 1.4.10 (AA), 1.4.12 (AA)
Pointer targetsClick and tap targets are at least 24×24px (44×44px for AAA), or spaced so they don't overlap.2.5.8 (AA), 2.5.5 (AAA)
MotionAnimations respect the reduced-motion setting.2.3.3 (AAA)