🚀 React Markdown typing animation component for modern chat interface effects
🇺🇸 English | 🇨🇳 中文
A React component designed specifically for modern AI applications, providing smooth real-time typing animations and complete Markdown rendering capabilities.
-
Streaming Data Typing Stuttering Issues
Traditional typewriter components experience stuttering and character jumping when processing AI backend streaming data, as each chunk contains multiple characters. ds-markdown intelligently splits each chunk to ensure smooth typing for every character. -
Markdown Rendering and Typing Animation Disconnection
Most typewriter components only support plain text and cannot render Markdown syntax, mathematical formulas, charts, and other rich media content in real-time during typing.
-
Enhanced User Immersion
Provides professional-level AI chat experience, allowing users to feel authentic AI interaction processes, greatly improving product professionalism and user satisfaction. -
Out-of-the-box, Reduces Development Complexity
Complete solution that requires no additional configuration to support streaming data, Markdown rendering, mathematical formulas, charts, and other complex features.
If you don't need any styles and want full control over rendering, we recommend using react-markdown-typer
- 🤖 AI Chat Ready - Professional typing animation for AI streaming responses
- 📝 Full Markdown Support - Code highlighting, tables, lists, and more
- 🔢 Math Formulas - KaTeX support with
$...$and$$...$$syntax - 📊 Mermaid Charts - Flowcharts, sequence diagrams, Gantt charts, etc.
- 🎨 Customizable - Light/dark themes, configurable typing speed
- ⚡ High Performance - Lightweight, smooth animations
- 🔌 Extensible - Plugin system for custom functionality
- 📦 TypeScript - Full type support
# npm
npm install ds-markdown
# yarn
yarn add ds-markdown
# pnpm
pnpm add ds-markdownimport DsMarkdown from 'ds-markdown';
function App() {
return (
<DsMarkdown interval={20} answerType="answer">
# Hello ds-markdown This is a **high-performance** typing animation component! ## Features - ⚡ Zero-delay streaming processing - 🎬 Smooth typing animation - 🎯 Perfect syntax support
</DsMarkdown>
);
}For detailed documentation, please visit: Full Documentation
import DsMarkdown, { MarkdownCMD } from 'ds-markdown';| Property | Type | Description | Default Value |
|---|---|---|---|
interval |
number | IntervalConfig |
Typing interval configuration, supports fixed interval or dynamic speed control | 30 |
timerType |
'setTimeout' | 'requestAnimationFrame' |
Timer type, does not support dynamic modification | Current default is setTimeout, will change to requestAnimationFrame later |
answerType |
'thinking' | 'answer' |
Content type (affects style theme), does not support dynamic modification | 'answer' |
theme |
'light' | 'dark' |
Theme type | 'light' |
plugins |
IMarkdownPlugin[] |
Plugin configuration | [] |
math |
IMarkdownMath |
Mathematical formula configuration | { splitSymbol: 'dollar' } |
onEnd |
(data: EndData) => void |
Typing completion callback | - |
onStart |
(data: StartData) => void |
Typing start callback | - |
onBeforeTypedChar |
(data: IBeforeTypedChar) => Promise<void> |
Callback before character typing, supports async operations, blocks subsequent typing | - |
onTypedChar |
(data: ITypedChar) => void |
Callback after each character typing | - |
disableTyping |
boolean |
Disable typing animation effects | false |
autoStartTyping |
boolean |
Whether to automatically start typing animation, set to false for manual trigger, does not support dynamic modification | true |
codeBlock |
IMarkdownCode |
Code block configuration | {headerActions: true} |
Note: If
disableTypingchanges fromtruetofalseduring typing, it will only continue from the current position and will not replay the skipped animation; to replay from the beginning, please call the instance methodrestart().
For detailed documentation, please visit: Full Documentation
- react-markdown-typer - If you need a lightweight markdown typing component
- ds-markdown-mermaid-plugin - Mermaid chart support plugin
MIT © onshinpei
Contributions, issues and feature requests are welcome!