PeakUI

ErrorMessage

Error text displayed through a parent's error slot

Usage

import {ErrorMessage} from "@peakui/react";

ErrorMessage presents the errorMessage slot of a parent such as TagGroup; the parent decides when the message shows. For a form field's validation errors, use FieldError, which renders them while the field is invalid.

Outside a parent that publishes the errorMessage slot, ErrorMessage still renders its <span>, but nothing links it to a control. Inside such a parent, the message is announced with it through aria-describedby while it is mounted.

Customization

Tailwind CSS

Global CSS

@layer components {
  .error-message {
    @apply text-sm font-medium;
  }
}

Styling Reference

CSS Classes

The ErrorMessage component uses this CSS class (view source styles):

  • .error-message - Base error message styles

Slots

  • [data-slot="error-message"]

API Reference

ErrorMessage

PropTypeDefaultDescription
childrenReact.ReactNode-The error message
classNamestring-Additional classes
elementTypestring'span'The element to render
renderDOMRenderFunction<any, any>-Replaces the rendered element with your own. React Aria types it loosely because elementType can change the element

The slot defaults to errorMessage; it is what links the message to the parent, so leave it as it is.

On this page