Skip to content
Redpanda UI
Esc
↑↓navigate↵open⌘Jpreview
Edit on GitHub

Form Error Summary

An accessible summary of field validation and structured server errors.

Powered by

Installation

Configure the public Buf package registry before installing; structured error details depend on its generated Google RPC SDK.

bash
npx shadcn@latest add @redpanda/form-error-summary
bash
pnpm dlx shadcn@latest add @redpanda/form-error-summary
bash
yarn dlx shadcn@latest add @redpanda/form-error-summary
bash
bunx shadcn@latest add @redpanda/form-error-summary
bash
nubx shadcn@latest add @redpanda/form-error-summary
bash
aube dlx shadcn@latest add @redpanda/form-error-summary

The example validates locally, then simulates a structured rate-limit response. It does not send profile data to a server.

Usage

Place the summary inside your existing FormProvider or registry Form. It subscribes to field errors and submit count directly, including in React Compiler builds; the parent does not need to read formState to force updates.

tsx
import { FormErrorSummary } from '@/components/ui/form-error-summary';
<FormErrorSummary />;

The summary is hidden before the first submission by default. With React Hook Form’s criteriaMode: 'all', it includes every distinct supplied message for each field, not just the first criterion. Identical primary and criterion messages appear once. An error leaf without a message remains visible as “Invalid value.”

For standalone use, provide both errors and submitCount. Explicit props take precedence over provider values.

tsx
<FormErrorSummary errors={{ username: { type: 'required', message: 'Enter a username.' } }} submitCount={1} />

Field focus

Activating a field error focuses the corresponding name or data-name control. A summary inside a native form resolves that form’s controls, including inputs associated through the native form attribute, rather than selecting the first matching name elsewhere on the page.

Outside a form, the summary can focus an unambiguous document target. If the same field appears in multiple forms, it reports the ambiguity instead of focusing a potentially unrelated form. Missing or unavailable targets also produce visible feedback. Use focusOnClick={false} for a noninteractive list.

labelForPath takes precedence over autoLabels. autoLabels reads protobuf summary-label annotations, with a humanized leaf-name fallback. Without either option, labels remain the original field paths.

Structured server context

Pass a ConnectErrorContext from extractConnectErrorContext in @/lib/format-error. The summary can display the backend message, every precondition and quota violation, help links, a copyable request ID, and a retry hint for resource-exhausted responses. Text is rendered as text, not HTML.

The retry hint counts down while the summary is hidden by minSubmitCount, stops at zero, and resets when the supplied retry duration changes. It is informational: it does not disable submission or automatically retry a request.

Debug visibility

Backend debug details are absent by default, including during server rendering. Enable showDebug only from trusted development configuration, with the same value on the server and during hydration. Do not expose private backend diagnostics through a user-controlled toggle.

The demo’s toggle reveals fabricated development data only. JSON-like detail strings remain literal text, and stack entries use an ordered list of code fragments.

Props

Prop Default Purpose
errors Provider errors Field errors; nested paths and all supplied criteria messages are preserved.
submitCount Provider count, otherwise 0 Current submission count.
minSubmitCount 1 Submission threshold before the summary can appear.
context — Structured backend error context.
title Fix the following before submitting Summary title.
description — Secondary helper text.
focusOnClick true Enable field-focus actions.
labelForPath — Explicit path-to-label function.
autoLabels — Protobuf schema used to derive labels.
showDebug false Explicit development-only debug opt-in.
testId form-error-summary Test identifier for the alert root.

See the primary documentation for all-criteria validation and Connect error details.

Recent changes

  • patchv1.2.0Pin shipped dependency floors to the version we develop against. Registry items now declare ranges like `^5.1.9` (the actual installed version) instead of collapsing to `^5.0.0`, so consumers start on the known-tested baseline while caret semantics still allow any compatible release within the same major.#133
  • minorv1.2.0Port the auto-form subsystem from ADP UI back to the registry.#122
  • minorv1.1.0Theme docs refresh, readability pass on semantic foregrounds, and consumer-facing Base UI regression fixes.#121
  • minorv1.0.0Post-Base-UI polish. Public API unchanged.#116
  • majorv1.0.0Migrate every Radix-based primitive to `@base-ui/react@^1.4.0` (Base UI).#114
See full history →

Last updated on

Was this page helpful?