Components
FieldErrors
The container for validation errors for a Field, Fieldset, or ElementField.
The FieldErrors
component renders the following structure by default (attributes omitted for brevity):
Notice that we're populating the fallback slot, so if you don't provide a slot for the FieldErrors
component, it will render a <div>
element for each error in the errors
array.
The errors
are the errors for the Field, Fieldset, or ElementField that the FieldErrors
component is associated with and must be used within the context of one of those components.
The errors container is automatically linked to the control of the field using the aria-describedby
attribute when errors are present.
Usage
Basic Usage
By default, the FieldErrors
component will render a <div>
element with the errors for the field it is associated with.
Custom Error Rendering
If you want to customize the rendering of the errors, you can access the errors using the errors
slot prop and render them however you'd like.
Props
The FieldErrors
component accepts all props that a standard HTML <div>
element would accept along with a few additional props:
Slot Props
The FieldErrors
component provides three slot props, fieldErrorsAttrs
, which is only necessary when using the asChild prop, errors
, which is an array representing the errors for the field that the FieldErrors
component is associated with, and errorAttrs
, which are attributes that can (optionally) be spread onto each individual error element being rendered.
Attributes
Field Errors Container
The following attributes are automatically applied to the container rendered by the FieldErrors
component. This is also the shape of the fieldErrorsAttrs
slot prop when using the asChild prop.
Error Elements
The following attributes are automatically applied to the individual error elements rendered by the FieldErrors
component. This is also the shape of the errorAttrs
slot prop.