On this page

Markdown

Markdown an toàn, giữ block ổn định khi câu trả lời đang streaming.

Copy page as MarkdownRead Markdown ↗

Key rules

  • Element prototype là chuẩn để chatty-ui port theo.
  • Host giữ dữ liệu, dịch nhãn và xử lý event; preview chỉ dùng dữ liệu cục bộ.
On this page

Use when / Avoid

Dùng trong cuộc trò chuyện. Tránh nối trực tiếp element với API của shop.

Use instead

Component Use when
Markdown Implementation React đang chạy.
Element prototype Consumer chuyển sang custom element.

Live preview

Standard

Standard
LightDarkDesktopMobile

Element prototype với token trung tính.

Show code
chatty-markdown.element.jsWrap code linesCopy
<chatty-markdown
  text="## A useful reply&#10;&#10;**Canvas tote** for everyday trips. [Details](https://example.com/products/tote)&#10;&#10;- Lightweight&#10;- Reusable"
></chatty-markdown>

Admin chỉ dùng trong inbox và chỉ light; admin-dark là N/A. Surface chưa có React tương ứng ghi Not available bên dưới.

Parser giữ HTML thành chữ, chỉ cho phép navigation protocol an toàn. Renderer dựng template tree; không chèn HTML thô. Khi streaming, animate giữ delimiter chưa đóng. Hỗ trợ heading, list, quote, code, link và hard break của widget.

Element

Element Module
chatty-markdown @avada/chatty-ui/elements/markdown.js

API

Kind Name Type Default Description
attribute text string '' Markdown source; HTML is displayed literally.
attribute animate boolean false Holds unfinished inline delimiters during a stream.
part base Not available Not available Markdown document.
part link Not available Not available Safe navigation link.
css-property --chatty-markdown-link Not available Not available Link ink.
css-property --chatty-markdown-code-background Not available Not available Code background.

Classic

Current (React), being replaced
LightDarkDesktopMobile

Component React thật; dữ liệu fixture, không gửi request.

Show code
markdown.jsxWrap code linesCopy
import React, {useState} from 'react';
import ChatThread from '@scripttag/v2/views/ChatThread.jsx';
import {chatStore} from '@scripttag/v2/stores/chatStore.js';
import {WidgetTextRenderer} from '@assets/pages/InboxManagement/v2/blocks/WidgetTextRenderer.jsx';
import {Markdown} from '@avada/chatty-ui/primitives/Markdown.js';
import {MessageFrame} from '@avada/chatty-ui/canonical/MessageFrame.jsx';
import {CanonicalSurface} from '@avada/chatty-ui/canonical/Surface.jsx';
import {PreChatPrompt} from '@avada/chatty-ui/canonical/PreChatPrompt.jsx';
import {Composer} from '@avada/chatty-ui/primitives/Composer.js';

const message = {
  id: 'guide-reply',
  senderType: 'bot',
  text: 'The **canvas tote** is lightweight.',
  status: 'sent',
  createdAt: '2026-11-23T10:00:00Z',
};
const store = {getState: () => ({messages: [message], loading: false}), subscribe: () => () => {}};

export function MarkdownText() {
  return <Markdown text={message.text} />;
}

Token values dưới đây là fallback cục bộ; theme của caller có thể override.

Import / element

Component / element Import / file Scope root
Markdown @avada/chatty-ui/primitives/Markdown.js Markdown

Anatomy

Part Element
1 Markdown

Placement / order

Context Order
Conversation Caller supplies surrounding content

Props

Prop Type Values Default Notes
text See source Caller supplied See source Markdown source

Sizes

Size Height Padding Gap Radius Font role (px/rem) Hit target Breakpoint / mechanism
Paragraph Content Not available Bottom margin 0.75em Not available Inherited Not available Text flow

Tokens

Part Token Light Dark
Inline code fill --chatty-muted Fallback #f4f4f5 Fallback #f4f4f5
Link ink --chatty-link Fallback #2563eb Fallback #2563eb

States

State Trigger Visual change (values) ARIA/attribute
Streaming animate prop Unfinished inline markup held Not available

Behaviour

Interaction Result
Render text Escaped React tree

Copy

String i18n key Where
Caller translated Not available Markdown

Source

File Evidence
Owning React implementation.

AI Mode

Current (React), being replaced
LightDarkDesktopMobile

Component React thật; dữ liệu fixture, không gửi request.

Show code
markdown.jsxWrap code linesCopy
import React, {useState} from 'react';
import ChatThread from '@scripttag/v2/views/ChatThread.jsx';
import {chatStore} from '@scripttag/v2/stores/chatStore.js';
import {WidgetTextRenderer} from '@assets/pages/InboxManagement/v2/blocks/WidgetTextRenderer.jsx';
import {Markdown} from '@avada/chatty-ui/primitives/Markdown.js';
import {MessageFrame} from '@avada/chatty-ui/canonical/MessageFrame.jsx';
import {CanonicalSurface} from '@avada/chatty-ui/canonical/Surface.jsx';
import {PreChatPrompt} from '@avada/chatty-ui/canonical/PreChatPrompt.jsx';
import {Composer} from '@avada/chatty-ui/primitives/Composer.js';

const message = {
  id: 'guide-reply',
  senderType: 'bot',
  text: 'The **canvas tote** is lightweight.',
  status: 'sent',
  createdAt: '2026-11-23T10:00:00Z',
};
const store = {getState: () => ({messages: [message], loading: false}), subscribe: () => () => {}};

export function MarkdownText() {
  return <Markdown text={message.text} />;
}

Token values dưới đây là fallback cục bộ; theme của caller có thể override.

Import / element

Component / element Import / file Scope root
Markdown @avada/chatty-ui/primitives/Markdown.js Markdown

Anatomy

Part Element
1 Markdown

Placement / order

Context Order
Conversation Caller supplies surrounding content

Props

Prop Type Values Default Notes
text See source Caller supplied See source Markdown source

Sizes

Size Height Padding Gap Radius Font role (px/rem) Hit target Breakpoint / mechanism
Paragraph Content Not available Bottom margin 0.75em Not available Inherited Not available Text flow

Tokens

Part Token Light Dark
Inline code fill --chatty-muted Fallback #f4f4f5 Fallback #f4f4f5
Link ink --chatty-link Fallback #2563eb Fallback #2563eb

States

State Trigger Visual change (values) ARIA/attribute
Streaming animate prop Unfinished inline markup held Not available

Behaviour

Interaction Result
Render text Escaped React tree

Copy

String i18n key Where
Caller translated Not available Markdown

Source

File Evidence
Owning React implementation.

Admin

Not available — React component tương ứng không có trong surface này; không dựng preview giả.

Import / element

Component / element Import / file Scope root
Not available Not available Not available

Anatomy

Part Element
1 Not available

Placement / order

Context Order
Conversation Not available

Props

Prop Type Values Default Notes
Not available Not available Not available Not available Not available

Sizes

Size Height Padding Gap Radius Font role (px/rem) Hit target Breakpoint / mechanism
Not available Not available Not available Not available Not available Not available Not available Not available

Tokens

Part Token Light Dark
Not available Not available Not available Not available

States

State Trigger Visual change (values) ARIA/attribute
Not available Not available Not available Not available

Behaviour

Interaction Result
Not available Not available

Copy

String i18n key Where
Not available Not available Not available

Source

File Evidence
Shared React owner; no corresponding surface preview.

Do / Don't

Accessibility

Surface Role / name Keyboard / focus Live region Contrast pair / ratio
Classic Native content semantics Native links and actions remain keyboard accessible Not available See neutral token preview
AI Mode Native content semantics Native links and actions remain keyboard accessible Not available See neutral token preview
Admin Native content semantics Native links and actions remain keyboard accessible Not available See neutral token preview