# Message An unstyled message component for displaying inline notifications with close and auto-dismiss support. ## Features - Compound component API with five sub-components: `Root`, `Content`, `Icon`, `Text`, `Close` - Auto-close with configurable `life` duration - Close callback on dismissal ## Usage ```tsx import { Message } from 'primereact/message'; ``` ```tsx ``` ## Behavior ### Polymorphic Rendering Use `as` on any sub-component to change the rendered HTML element. ```tsx ``` Default elements: `Root`=`div`, `Content`=`div`, `Icon`=`span`, `Text`=`p`, `Close`=`button`. ### Render Function Children Sub-components accept a render function as children, providing access to the component instance. ```tsx {(instance) => {instance.message?.state.visible ? 'Visible' : 'Hidden'}} ``` ## Pass Through ## API ### MessageRoot | Attribute | Value | | ------------ | ----------- | | `data-scope` | `"message"` | | `data-part` | `"root"` | | Label | Type | Description | |:------|:------|:------| | root | MessageRootPassThroughType> | Used to pass attributes to the root's DOM element. | | content | MessageRootPassThroughType> | Used to pass attributes to the content's DOM element. | | icon | MessageRootPassThroughType> | Used to pass attributes to the icon's DOM element. | | text | MessageRootPassThroughType> | Used to pass attributes to the text's DOM element. | | close | MessageRootPassThroughType> | Used to pass attributes to the close's DOM element. | ### MessageContent | Attribute | Value | | ------------ | ----------- | | `data-scope` | `"message"` | | `data-part` | `"content"` | | Label | Type | Description | |:------|:------|:------| | root | MessageContentPassThroughType> | Used to pass attributes to the root's DOM element. | ### MessageIcon | Attribute | Value | | ------------ | ----------- | | `data-scope` | `"message"` | | `data-part` | `"icon"` | | Label | Type | Description | |:------|:------|:------| | root | MessageIconPassThroughType> | Used to pass attributes to the root's DOM element. | ### MessageText | Attribute | Value | | ------------ | ----------- | | `data-scope` | `"message"` | | `data-part` | `"text"` | | Label | Type | Description | |:------|:------|:------| | root | MessageTextPassThroughType> | Used to pass attributes to the root's DOM element. | ### MessageClose | Attribute | Value | | ------------ | ----------- | | `data-scope` | `"message"` | | `data-part` | `"close"` | | Label | Type | Description | |:------|:------|:------| | root | MessageClosePassThroughType> | Used to pass attributes to the root's DOM element. | ## Accessibility ### Screen Reader Message uses the `alert` role which implicitly sets `aria-live="assertive"` and `aria-atomic="true"`, ensuring the message content is announced immediately by screen readers. The close button is a native `