Loading...
Loading...
Compare original and translation side by side
react-markdownreact-markdownnpm install streamdownnpm install @streamdown/code @streamdown/mermaid @streamdown/math @streamdown/cjknpm install streamdownnpm install @streamdown/code @streamdown/mermaid @streamdown/math @streamdown/cjkglobals.css@source "../node_modules/streamdown/dist/*.js";tailwind.config.jsmodule.exports = {
content: [
"./app/**/*.{js,ts,jsx,tsx,mdx}",
"./node_modules/streamdown/dist/*.js",
],
};globals.css@source "../node_modules/streamdown/dist/*.js";tailwind.config.jsmodule.exports = {
content: [
"./app/**/*.{js,ts,jsx,tsx,mdx}",
"./node_modules/streamdown/dist/*.js",
],
};import { Streamdown } from 'streamdown';
<Streamdown>{markdown}</Streamdown>import { Streamdown } from 'streamdown';
<Streamdown>{markdown}</Streamdown>'use client';
import { useChat } from '@ai-sdk/react';
import { Streamdown } from 'streamdown';
import { code } from '@streamdown/code';
export default function Chat() {
const { messages, input, handleInputChange, handleSubmit, isLoading } = useChat();
return (
<>
{messages.map((msg, i) => (
<Streamdown
key={msg.id}
plugins={{ code }}
caret="block"
isAnimating={isLoading && i === messages.length - 1 && msg.role === 'assistant'}
>
{msg.content}
</Streamdown>
))}
<form onSubmit={handleSubmit}>
<input value={input} onChange={handleInputChange} disabled={isLoading} />
</form>
</>
);
}'use client';
import { useChat } from '@ai-sdk/react';
import { Streamdown } from 'streamdown';
import { code } from '@streamdown/code';
export default function Chat() {
const { messages, input, handleInputChange, handleSubmit, isLoading } = useChat();
return (
<>
{messages.map((msg, i) => (
<Streamdown
key={msg.id}
plugins={{ code }}
caret="block"
isAnimating={isLoading && i === messages.length - 1 && msg.role === 'assistant'}
>
{msg.content}
</Streamdown>
))}
<form onSubmit={handleSubmit}>
<input value={input} onChange={handleInputChange} disabled={isLoading} />
</form>
</>
);
}<Streamdown mode="static" plugins={{ code }}>
{content}
</Streamdown><Streamdown mode="static" plugins={{ code }}>
{content}
</Streamdown>| Prop | Type | Default | Purpose |
|---|---|---|---|
| | — | Markdown content |
| | | Rendering mode |
| | — | Feature plugins |
| | | Streaming indicator |
| | — | Cursor style |
| | — | Custom element overrides |
| | | Interactive buttons |
| | | Link confirmation modal |
| | | Code themes |
| | — | Container class |
| 属性 | 类型 | 默认值 | 用途 |
|---|---|---|---|
| | — | Markdown内容 |
| | | 渲染模式 |
| | — | 功能插件 |
| | | 流式传输状态指示器 |
| | — | 光标样式 |
| | — | 自定义元素覆盖 |
| | | 交互按钮 |
| | | 链接确认弹窗 |
| | | 代码主题 |
| | — | 容器类名 |
| Plugin | Package | Purpose |
|---|---|---|
| Code | | Syntax highlighting (Shiki, 200+ languages) |
| Mermaid | | Diagrams (flowcharts, sequence, etc.) |
| Math | | LaTeX via KaTeX (requires CSS import) |
| CJK | | Chinese/Japanese/Korean text support |
import 'katex/dist/katex.min.css';| 插件 | 包名 | 用途 |
|---|---|---|
| 代码 | | 语法高亮(基于Shiki,支持200+种语言) |
| Mermaid | | 图表渲染(流程图、序列图等) |
| 数学公式 | | 基于KaTeX渲染LaTeX公式(需导入CSS) |
| 中日韩文本 | | 中文/日文/韩文文本支持 |
import 'katex/dist/katex.min.css';assets/examples/assets/examples/@sourcecontentnode_modules/streamdown/dist/*.jskatex/dist/katex.min.csscaretisAnimating={true}isAnimating={true}linkSafety={{ enabled: false }}shikitranspilePackagesallowedTags$$$@sourcecontentnode_modules/streamdown/dist/*.jskatex/dist/katex.min.csscaretisAnimating={true}isAnimating={true}linkSafety={{ enabled: false }}shikitranspilePackagesallowedTags$$$