logoAnt Design X

DesignDevelopmentComponentsX MarkdownX SDKX SkillPlayground
  • Introduction
  • Code Examples
    2.0.0
  • Playground
  • Themes
  • Streaming
  • Components
    • Overview
    • Chat Enhancement
    • Data Display
    • Rich Text Enhancement
  • Plugins
    • Overview
    • Latex
    • CustomPlugins

Code Examples

Importimport { XMarkdown } from "@ant-design/x-markdown";
Sourcex-markdown/src/x-markdown
Docs
Edit this page
Versionsupported since 2.0.0

When to Use

Use this page to get a minimal setup for rendering LLM Markdown output.

Code Examples

API

PropertyDescriptionTypeDefault
contentMarkdown content to renderstring-
childrenMarkdown content (use either content or children)string-
componentsMap HTML nodes to custom React componentsRecord<string, React.ComponentType<ComponentProps> | keyof JSX.IntrinsicElements>-
streamingStreaming behavior configStreamingOption-
configMarked parse config, applied last and may override built-in renderersMarkedExtension{ gfm: true }
rootClassNameExtra CSS class for the root elementstring-
classNameExtra CSS class for the root containerstring-
paragraphTagHTML tag for paragraphs (avoids validation issues when custom components contain block elements)keyof JSX.IntrinsicElements'p'
styleInline styles for the root containerCSSProperties-
prefixClsCSS class name prefix for component nodesstring-
openLinksInNewTabAdd target="_blank" to all links so they open in a new tabbooleanfalse
dompurifyConfigDOMPurify config for HTML sanitization and XSS protectionDOMPurify.Config-
protectCustomTagNewlinesWhether to preserve newlines inside custom tagsbooleanfalse
escapeRawHtmlEscape raw HTML in Markdown as plain text (do not parse as real HTML), to prevent XSS while keeping content visiblebooleanfalse
debugEnable debug mode (performance overlay)booleanfalse

StreamingOption

FieldDescriptionTypeDefault
hasNextChunkWhether more chunks are expected. Set false to flush cache and finish renderingbooleanfalse
enableAnimationWhether to enable fade-in animation for block elementsbooleanfalse
animationConfigAnimation options (for example fade duration and easing)AnimationConfig-
incompleteMarkdownComponentMapMap incomplete Markdown fragments to custom loading componentsPartial<Record<'link' | 'image' | 'html' | 'emphasis' | 'list' | 'table' | 'inline-code', string>>{ link: 'incomplete-link', image: 'incomplete-image' }

Related Docs

  • Component Extension
  • Streaming
Basic Rendering

Smallest working setup

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code
Streaming Rendering

Syntax recovery + animation

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code
Component Extension

Map code block to CodeHighlighter

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code
Plugin Extension

Extend Markdown syntax

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code
Security & Links

Escape raw HTML and open links in new tab; see Streaming format demo for dompurifyConfig

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code
动画
语法处理
Escape raw HTML
Open links in new tab