2.10.0
中文
Skip to content

Introduction ​

Stream-friendly, extensible Markdown rendering component. Aligns with the core capabilities of @ant-design/x-markdown@2.10.0: formulas, code highlighting, Mermaid, stream syntax, and custom component mapping.

When to use ​

  • Render Markdown content in chat bubbles, messages, and other scenarios
  • Use streaming and useStreaming when streaming output is needed
  • Use components mapping when custom headers, code blocks, Mermaid, and other nodes are needed

More detailed pages:

Examples ​

Basic usage ​

Hello World

Welcome to XMarkdown!

  • Item 1
  • Item 2
  • Item 3
const a = 1;
Basic usage

You can render by passing a Markdown string through content.

Custom components mapping ​

Custom Blue Title

Normal H2

Paragraph with bold and italic.

Custom components mapping

Map HTML tags to custom Vue components through components, which can receive props like domNode, streamStatus, children, etc.

Streaming render ​

Status: idle
Streaming render

Use streaming to indicate streaming state, combined with useStreaming to handle content and state.

API ​

The full table (including children, paragraphTag, openLinksInNewTab, dompurifyConfig, componentsProps, escapeRawHtml, disableDefaultStyles, protectCustomTagNewlines, disableCustomTagBlockMarkdown, rootClassName, style, etc.) can be found in Code Examples · API. Common fields are listed here:

XMarkdownProps ​

PropDescriptionTypeDefault
contentMarkdown contentstring-
childrenAlias for contentstring-
streamingStreaming configuration. Boolean indicates whether it is still outputting; object supports hasNextChunk, enableAnimation, animationConfig, incompleteMarkdownComponentMapboolean | StreamingOption-
componentsMaps tag names to custom Vue components (e.g., h1, pre, code, mermaid, think)Record\<string, Component\>-
paragraphTagParagraph HTML tag, avoid illegal nesting of custom block componentsstring'p'
pluginsList of plugins, transforms content before parsingany[]-
configMarked parsing configurationMarkedConfig-
openLinksInNewTabAdd target="_blank" to all linksbooleanfalse
dompurifyConfigDOMPurify sanitization configurationDOMPurify.Config-
classNameRoot class namestring-
rootClassNameAlias of classNamestring-
styleRoot inline styleCSSProperties-

StreamingOption / AnimationConfig ​

FieldDescriptionDefault
hasNextChunkThere is another chunk following. Unclosed syntax is not fully parsed as Markdownfalse
enableAnimationText fade-infalse
animationConfig.fadeDurationFade-in duration (milliseconds)200
animationConfig.easingEasing'ease-in-out'
incompleteMarkdownComponentMapComponent names for unfinished syntax (token is link / image / html / emphasis / list / table){}

ComponentProps (custom component props) ​

PropDescriptionType
domNodeParsed DOM node information (name, attribs, children)DOMNode
streamStatusWhen a custom tag is not closed, it is 'loading'; after closing, it is 'done'. code can read data-state`'loading'
blockOnly for code: when data-block="true", it is block-level codeboolean
childrenChild content (VNode or text)`VNode[]
othersStandard HTML attributes and data-* etc.Record\<string, any\>

useStreaming ​

Used as a composable function for streaming content.

ArgumentDescriptionType
contentContent refRef\<string\>
streamingRef indicating whether streaming is in progress (optional)Ref\<boolean\>
onCompleteCallback when streaming ends() => void
Return valueDescriptionType
displayedContentCurrently displayed contentRef\<string\>
statusStatus: idlestreaming
isStreamingWhether it is streamingRef\<boolean\>

Exports ​

  • XMarkdown - Main component
  • AnimationText - Text fade-in component (streaming.enableAnimation)
  • useStreaming - Streaming composition function
  • parseMarkdown(content, config?) - Parse Markdown into HTML
  • htmlToVNode(html, options?) - Convert HTML to VNode (supports components, streamStatus)