Skip to content
THE COMPONENT LIBRARY
Skip to content

Component reference

FormError

Field-level validation and server feedback connected to Form state.

Connect validation and server errors

FormError reads a field message from Form. Use validation, setError and clearErrors to manage its content, and named-part classes to customize its presentation.

FormError — show and customize field feedback

FormError reads errors[name] from its parent Form. Its required name must match the registered field key. It renders a role=alert paragraph only when that field has a message; register connects the field's aria-describedby and aria-invalid attributes to it.

Return messages from validate or call form.setError(name, message) for a server response. Editing a registered field clears its error; clearErrors removes the message explicitly. Use className or classNames.error to style the message while preserving its association and alert role.

FormError — show and customize field feedbackOpen preview

New to Pimolu? Follow the Quick start or the Next.js guide for the shared stylesheet and application provider.

Preview

Live preview

Changes apply to this preview only.

Loading the interactive example?

Width adapts to the available space

More examples

Different configurations and compositions using the real Pimolu API. Each preview runs independently and follows the site appearance.

Validate on blur

Choose when to set a field message and clear it on editing.

Open preview

Styled Select integration

Connect a control using onValueChange with explicit ARIA associations.

Open preview

Named-part customization

Style the error slot while preserving its alert role and field association.

Open preview

Usage

Place FormError inside Form with a name matching a field key. It reads form.errors[name] and renders nothing when there is no message. Return an error map from validate or call form.setError(name, message) after a server response.

Spread form.register(name) onto a native-event input such as Input. Registration connects aria-invalid and aria-describedby to the message. For controls exposing onValueChange, connect form.values, setValue and those ARIA attributes explicitly.

Editing a registered field or calling setValue clears its error. clearErrors(name) removes one error; clearErrors() removes all. FormError only renders feedback: it does not run validation or submit the form.

Customize the message with className or classNames.error, or provide Form-level classNames.error for shared styling. Preserve the generated id and alert role. The current API displays a text message; it does not accept arbitrary children or Button props.

API reference

Generated from the public TypeScript declarations. Native HTML attributes are inherited where the component extends them; this reference includes Pimolu props and selected common native attributes.

PimoluFormErrorProps

Type source
PimoluFormErrorProps public API
NameTypeDefaultDescription
classNamesPimoluClassNames<"form"> | undefined—Additive classes for stable named parts, including composed descendants. Parts: endIcon, error, label, root, spinner, startIcon, submit. Parts render only when the corresponding component or state is present.
nameRequiredstring—Registered field name.
classNamestring | undefined—Public Pimolu prop; see the source declaration for details.
classNames

PimoluClassNames<"form"> | undefined

No default extracted.

Additive classes for stable named parts, including composed descendants. Parts: endIcon, error, label, root, spinner, startIcon, submit. Parts render only when the corresponding component or state is present.

nameRequired

string

No default extracted.

Registered field name.

className

string | undefined

No default extracted.

Public Pimolu prop; see the source declaration for details.

Accessibility

  • Keep the error next to its field and explain how to correct it. The message is a paragraph with role=alert and a stable id associated with the registered control.
  • Do not rely on color alone. Validation does not automatically focus the first invalid field; decide how your application should handle focus and an error summary.
Read the accessibility guide →