Usage
Chat Message groups one speaker’s content within the Chat family without taking ownership of its child nodes.
import "@nordhealth/components/lib/ChatMessage"
Composition
Chat Message represents one accessible speaker turn. Its avatar and name identify the sender, its default content holds one or more message fragments, and its metadata slot follows that content with supporting state or actions. Sender and density context flow to direct Chat Message Bubble and Chat Message Metadata descendants without moving or replacing consumer nodes.
Examples
Sender and content
Set sender to assistant, user, or system. The message passes sender and density context to direct Chat Message Bubble and Chat Message Metadata descendants, aligning them at the logical edge without reversing source or keyboard order. Use avatar and name for simple sender content, or the corresponding slots for richer presentation.
Place one or more Chat Message Bubble elements in the default content and metadata in the metadata slot. Consumer nodes, listeners, and application state remain unchanged across updates.
Accessibility
The component derives a message label from the sender name when the consumer has not supplied aria-label; a consumer-provided label remains authoritative. Keep the name meaningful, retain chronological DOM order, and do not rely on left/right alignment alone to communicate authorship.
Templates
See this component composed into complete application views:
API reference
ChatMessage
Chat Message groups one speaker's avatar, name, bubbles, and metadata without taking ownership of consumer-authored message content.
<nord-chat-message></nord-chat-message>Props
| Property | Attribute | Description | Type | Default |
|---|---|---|---|---|
sender | sender | The semantic sender of the message. | ChatMessageSender | 'assistant' |
density | density | Optional density override. Otherwise inherits the surrounding chat density. | ChatDensity | undefined | — |
name | name | Sender name used for the visible label and accessible message name. | string | undefined | — |
avatar | avatar | URL for an owned Nord Avatar. Use the avatar slot for custom content. | string | undefined | — |
Slots
| Slot name | Description |
|---|---|
Default slot | Message bubbles and other consumer-owned message content. |
avatar | Consumer-provided avatar content, replacing the avatar URL. |
name | Consumer-provided sender name. |
metadata | Consumer-provided message metadata. |
Dependencies
This component is internally dependent on the following components: