Introducing PrimeReact v11-alpha 🎉Discover Now

Message

Message component is used to display inline messages.

Upgrade now and save %5.

preview

Installation#

npx shadcn@latest add @primereact/message

Usage#

import { Message, MessageClose, MessageContent, MessageIcon, MessageText } from '@/components/ui/message';
<Message severity="info">
    <MessageContent>
        <MessageIcon />
        <MessageText>Message text</MessageText>
        <MessageClose />
    </MessageContent>
</Message>

Examples#

Basic#

An inline message for informational, success, warning, or error feedback.

Upgrade now and save %5.

basic-demo

Severity#

The severity option specifies the type of the message.

Your account is now ready.

Upgrade now and save %5.

Your subscription is about to expire. Renew

Something went wrong. Please try again.

Processing may take a few moments.

You're currently in offline mode.

severity-demo

Icon#

Message.Icon is used to display an icon.

Your subscription is about to expire. Renew

How may I help you?

icon-demo

Variant#

Configure the variant value as outlined or simple.

Outlined

Your account is now ready.

Upgrade now and save %5.

Your subscription is about to expire. Renew

Something went wrong. Please try again.

Processing may take a few moments.

You're currently in offline mode.

Simple

Your account is now ready.

Upgrade now and save %5.

Your subscription is about to expire. Renew

Something went wrong. Please try again.

Processing may take a few moments.

You're currently in offline mode.

variant-demo

Sizes#

Message provides small and large sizes as alternatives to the base.

Upgrade now and save %5.

Upgrade now and save %5.

Upgrade now and save %5.

sizes-demo

Dynamic#

Multiple messages can be displayed.

dynamic-demo

Closable#

Message.Close is a triggerable element used to close the message.

This is a closable message.

closable-demo

Life#

Messages can disappear automatically by defined the life in milliseconds.

life-demo

Accessibility#

Screen Reader#

Message component uses 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. The closeButtonProps can be used to customize the element and override the default aria-label.

Close Button Keyboard Support#

KeyFunction
enterCloses the message.
spaceCloses the message.