📄 primereact/message

File: message.md | Updated: 11/15/2025

Source: https://primereact.org/message/

Introducing PrimeReact v11 Alpha 🥁Learn More

Message

Message component displays information related to another element such as invalid input.

Import#


import { Message } from 'primereact/message';
         

Copy

Basic#


Text to display is defined with the text property.

Username is required

<Message text="Username is required" />
         

Copy

Severity#


The severity property specifies the type of the message.

Success Message

Info Message

Warning Message

Error Message

Secondary Message

Contrast Message

<Message severity="info" text="Info Message" />
<Message severity="success" text="Success Message" />
<Message severity="warn" text="Warning Message" />
<Message severity="error" text="Error Message" />
<Message severity="secondary" text="Secondary Message" />
<Message severity="contrast" text="Contrast Message" />
         

Copy

Form#


Message component is handy when displaying error messages next to form elements.

Username

Username is required

Email

<div className="flex flex-wrap align-items-center mb-3 gap-2">
    <label htmlFor="username" className="p-hidden-accessible">Username</label>
    <InputText id="username" placeholder="Username" className="p-invalid mr-2" />
    <Message severity="error" text="Username is required" />
</div>
<div className="flex flex-wrap align-items-center gap-2">
    <label htmlFor="email" className="p-hidden-accessible">Email</label>
    <InputText id="email" placeholder="Email" className="p-invalid mr-2" />
    <Message severity="error" />
</div>
         

Copy

Template#


Custom content is displayed with the content property.

logo

Always bet on Prime.

<Message
style={{
    border: 'solid #696cff',
    borderWidth: '0 0 0 6px',
    color: '#696cff'
}}
className="border-primary w-full justify-content-start"
severity="info"
content={content}
/>
         

Copy

Accessibility#


Screen Reader

Message components use alert role that implicitly defines aria-live as "assertive" and aria-atomic as "true". Since any attribute is passed to the root element, attributes like aria-labelledby and aria-label can optionally be used as well.

Close element is a button with an aria-label that refers to the aria.close property of the locale API by default, you may use_closeButtonProps_ to customize the element and override the default aria-label.

Close Button Keyboard Support

| Key | Function | | --- | --- | | enter | Closes the message. | | space | Closes the message. |

  • Import

  • Basic

  • Severity

  • Form

  • Template

  • Accessibility

PrimeReact 10.9.7 by PrimeTek