logoAnt Design X

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

Streaming Rendering

Handle LLM streamed Markdown output: syntax completion and caching, animation, and tail suffix.

Code Examples

API

streaming

ParameterDescriptionTypeDefault
hasNextChunkWhether more chunks are comingbooleanfalse
incompleteMarkdownComponentMapComponent mapping for incomplete syntaxPartial<Record<Exclude<StreamCacheTokenType, 'text'>, string>>{}
enableAnimationEnable fade-in animationbooleanfalse
animationConfigAnimation configAnimationConfig{ fadeDuration: 200, easing: 'ease-in-out' }
tailEnable tail indicatorboolean | TailConfigfalse

TailConfig

PropertyDescriptionTypeDefault
contentContent to display as tailstring'▋'
componentCustom tail component, takes precedence over contentReact.ComponentType<{ content?: string }>-

AnimationConfig

PropertyDescriptionTypeDefault
fadeDurationDuration in msnumber200
easingCSS easing functionstring'ease-in-out'

The tail displays ▋ by default. You can customize the character via content, or pass a custom React component via component for animations, delayed display, and other effects.

tsx
// Custom tail component example
const DelayedTail: React.FC<{ content?: string }> = ({ content }) => {
const [visible, setVisible] = useState(false);
useEffect(() => {
const timer = setTimeout(() => setVisible(true), 2000);
return () => clearTimeout(timer);
}, []);
if (!visible) return null;
return <span className="my-tail">{content}</span>;
};

debug

PropertyDescriptionTypeDefault
debugWhether to enable performance monitor panelbooleanfalse

⚠️ debug is for development only. Disable in production to avoid overhead and information leakage.

Supported Incomplete Types

TokenTypeExample
link[text](https://example
image![alt](https://img...
heading###
table| col1 | col2 |
xml<div class="

Minimal Setup

tsx
<XMarkdown
content={content}
streaming={{
hasNextChunk,
enableAnimation: true,
tail: true,
incompleteMarkdownComponentMap: {
link: 'link-loading',
table: 'table-loading',
},
}}
components={{
'link-loading': LinkSkeleton,
'table-loading': TableSkeleton,
}}
/>

FAQ

Can hasNextChunk always be true?

No. Set it to false for the last chunk so placeholders can be flushed into final rendered content.

Syntax Processing

Incomplete syntax recovery and placeholders

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

Fade-in, tail cursor, and debug switches (slower stream pace for observation)

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code
Markdown Source
Rendered Output