Key rules
chatty-messagekhai báo 6 attribute, 6 property không có attribute, 0 event, 5 slot, 6 part và 1 CSS custom property.- Import 1 module
@avada/chatty-ui/elements/message.jslà definechatty-message; chunk chỉ import element nó dùng. Prototype chuẩn: trong guide. - Đổi tên attribute, event, slot, part hay CSS custom property là đổi API: diff của custom-elements.json phải có trong 1 MR.
On this page
Overview
A canonical message with sender grouping and registered rich blocks. Class ChattyMessage.
Attributes
| Name | Property | Type | Default | Description |
|---|---|---|---|---|
message |
message |
Object | null |
null |
Canonical message; keep untouched message references stable. |
message- |
messageId |
string |
'' |
Stable ID selected from store. |
viewer- |
viewerType |
string |
'customer' |
Sender type displayed on the trailing side. |
self- |
selfTypes |
Array<string> | null |
null |
Sender types on the trailing side; null falls back to viewerType. |
surface |
surface |
string |
'' |
Visual surface; inferred from the consumer theme root. |
locale |
locale |
string |
'en' |
Locale used for clocks and full datetimes. |
Properties
Attributes also expose the properties listed in the Property column above.
| Name | Type | Default | Description |
|---|---|---|---|
prev |
Object | null |
null |
Previous canonical message for direct rendering. |
next |
Object | null |
null |
Next canonical message for direct rendering. |
store |
Object | null |
null |
Canonical store, optionally owned by chatty- |
strings |
object |
{ |
Translated sender, delivery, rich- |
renderMessage |
Function | null |
null |
Trusted callback returning sender, badge, meta and actions Lit content per message. |
registry |
Object | null |
– | Trusted Map- |
Events
Not declared in the manifest.
Slots
| Name | Description |
|---|---|
| default | Additional block content. |
sender |
Readable sender at the start of a run. |
badge |
Sender badge. |
meta |
Metadata after the message. |
actions |
Message actions. |
Parts
| Name | Description |
|---|---|
base |
Message row. |
bubble |
Message text. |
blocks |
Rich blocks before or after the message text. |
sender |
Sender label and badge. |
meta |
Metadata wrapper. |
actions |
Actions wrapper. |
CSS custom properties
| Name | Default | Description |
|---|---|---|
- |
– | Bubble radius. |
Usage
import '@avada/chatty-ui/tokens/tokens.css';
import {html} from 'lit';
import '@avada/chatty-ui/elements/message.js';
const message = {
id: 'answer',
senderType: 'bot',
senderName: 'Assistant',
text: 'Try the **canvas tote**. It is lightweight and reusable.',
status: 'sent',
createdAt: '2026-01-15T10:01:00Z',
};
export function Standard() {
return html`<chatty-message .message=${message} viewer-type="customer"></chatty-message>`;
}
Live preview
Component thật dùng cùng story với trang component; dữ liệu mẫu nằm trong frame cục bộ.
Default: trạng thái mặc định và nội dung mẫu của element.
Show code
import '@avada/chatty-ui/tokens/tokens.css';
import {html} from 'lit';
import '@avada/chatty-ui/elements/message.js';
const message = {
id: 'answer',
senderType: 'bot',
senderName: 'Assistant',
text: 'Try the **canvas tote**. It is lightweight and reusable.',
status: 'sent',
createdAt: '2026-01-15T10:01:00Z',
};
export function Standard() {
return html`<chatty-message .message=${message} viewer-type="customer"></chatty-message>`;
}Các variant hoặc state chính đặt cạnh nhau trong cùng ví dụ.
Show code
import '@avada/chatty-ui/tokens/tokens.css';
import {html} from 'lit';
import '@avada/chatty-ui/elements/message.js';
const message = {
id: 'answer',
senderType: 'bot',
senderName: 'Assistant',
text: 'Try the **canvas tote**. It is lightweight and reusable.',
status: 'sent',
createdAt: '2026-01-15T10:01:00Z',
};
export function Centered() {
return html`<chatty-message
.message=${{
id: 'joined',
senderType: 'system',
layout: 'centered',
text: 'Agent joined',
createdAt: '2026-01-15T10:05:00Z',
}}
></chatty-message>`;
}Anatomy
Số trong hình khớp bảng bên dưới. Phần chỉ hiện ở state khác được ghi Not shown; ví dụ không thêm phần tử giả.
Anatomy: một instance mặc định riêng, có khoảng trống quanh các phần được đánh số.
Show code
import '@avada/chatty-ui/tokens/tokens.css';
import {html} from 'lit';
import '@avada/chatty-ui/elements/message.js';
const message = {
id: 'answer',
senderType: 'bot',
senderName: 'Assistant',
text: 'Try the **canvas tote**. It is lightweight and reusable.',
status: 'sent',
createdAt: '2026-01-15T10:01:00Z',
};
export function Standard() {
return html`<chatty-message .message=${message} viewer-type="customer"></chatty-message>`;
}| Part | Element | Source |
|---|---|---|
| 1 | CSS part base |
chatty- |
| 2 | CSS part bubble |
chatty- |
| 3 | CSS part blocks |
chatty- |
| 4 | CSS part sender |
chatty- |
| 5 | CSS part meta |
chatty- |
| 6 | CSS part actions |
chatty- |
Keyboard
No element-specific keys.
Source
- chatty-ui/custom-elements.json