翻篇收录说明
翻篇网页快照

Configuration

https://streamdown.ai/docs/configuration

最近抓取:2026-12-04 08:46:03(北京时间)

最近内容变化:2026-11-30 02:18:18(北京时间)

这是最近一次有效抓取的文本快照,不含网页脚本、图片和动态交互内容。实际网页可能已更新。

访问原网页

页面简介

Learn how to configure Streamdown in your project.

正文摘录

MenuConfigurationCopy for LLMView MarkdownAsk AI about this pageStreamdown can be configured to suit your needs. This guide will walk you through the available options and how to configure them. Core Props PropTypeDefaultDescriptionchildren?stringThe Markdown content to renderparseIncompleteMarkdown?booleantrueEnable remend preprocessor for unterminated Markdown blocksremend?RemendOptionsConfigure which Markdown completions remend should performnormalizeHtmlIndentation?booleanfalseNormalize indentation in HTML blocks to prevent 4+ space indents from being treated as code blocksisAnimating?booleanfalseIndicates if content is currently streaming (disables copy buttons)className?stringCSS class for the container elementmode?"streaming" | "static"streamingMode of the Streamdown componentdir?"auto" | "ltr" | "rtl"Text direction. 'ltr'/'rtl' force a single direction. 'auto' detects per block (content-majority strong characters, first-strong on ties). Code is always LTR. Text direction (dir) Use dir when rendering RTL languages (Persian, Arabic, Hebrew, etc.) or mixed-script content: app/page.tsx<Streamdown dir="auto" mode="static"> {markdown} </Streamdown> ValueBehavior"ltr" / "rtl"Applies that direction to the root (static) or each streaming block"auto"Detects direction independently per blockomittedNo dir attribute is set With dir="auto": Streaming mode — direction is resolved once per parsed markdown block (same unit used for memoized streaming updates). Static mode — a rehype pass assigns dir on each semantic block (headings, paragraphs, list items, blockquotes, definition terms/descriptions, captions, and table cells) so mixed Persian/Hebrew/Arabic/English documents keep the correct base direction without splitting the document (footnotes and cross-block references still resolve). Detection — counts Unicode strong letters after stripping common markdown syntax. The majority wins; equal counts fall back to the first strong character. Fenced and inline code are excluded from the count so LTR identifiers do not skew surrounding RTL prose. Code — fenced code blocks and code-related elements are always LTR so line numbers and syntax highlighting stay correct inside RTL documents. Styling Props PropTypeDefaultDescriptionshikiTheme?[ThemeInput, ThemeInput]['github-light', 'github-dark']Light and dark themes for code syntax highlighting. Accepts bundled theme names or custom theme objects (ThemeRegistrationAny).components?objectCustom component overrides for Markdown elementsfallbackComponent?React.ComponentType<Record<string, unknown> & ExtraProps>Fallback renderer for HTML tags or allowedTags entries that have no matching key in components. Built-in and explicit components entries always win — this is not a full unstyled mode. See Components.allowedTags?Record<string, string[]>Custom HTML tags to allow through sanitization, with their permitted attributes. Use with 'components' or 'fallbackComponent' to render custom tags like <ref> or <mention>. Only works with default rehype plugins.literalTagContent?string[]Tags whose children are treated as plain text (no markdown parsing). Useful when tag children contain underscores or asterisks that would otherwise be formatted. Tags must also appear in allowedTags.prefix?stringTailwind CSS prefix prepended to all utility classes. Enables Tailwind v4 prefix() support. User-supplied className values are also prefixed. Plugin Props PropTypeDefaultDescriptionrehypePlugins?Pluggable[]Object.values(defaultRehypePlugins)Rehype plugins for HTML processingremarkPlugins?Pluggable[]Object.values(defaultRemarkPlugins)Remark plugins for Markdown processingdisableAutolinkProtocols?string[]Disable GFM / CommonMark autolinking for specific URL protocols (e.g. ['mailto'] stops bare email addresses from becoming links). Accepts protocol names with or without a trailing colon, case-insensitive. Only affects autolinks (bare URLs/emails and <...> forms); explicit [text](url) links are unaffected, even when the label reconstructs the URL. Default Rehype Plugins: rehype-raw - HTML support rehype-sanitize - XSS protection and safe HTML rendering rehype-harden - Security hardening (permissive by default: allows all image and link prefixes, data images enabled; see Security to restrict image origins for AI chat apps) Default Remark Plugins: remark-gfm - GitHub Flavored Markdown Math rendering and CJK support require installing separate plugins. See Mathematics and CJK Language Support. Feature-Specific Props PropTypeDefaultDescriptionmermaid?MermaidOptionsMermaid diagram configuration and error handlingcontrols?ControlsConfigtrueControl visibility of interactive buttons, custom download filenames, and copy callbacks (`onCopy` / `onError`) for code, tables, and mermaid diagrams.lineNumbers?booleantrueShow line numbers in code blocks. Can be overridden per block with the noLineNumbers meta string.codeBlockRawLanguages?string[][]Code fence languages rendered verbatim as plain monospace text (no syntax highlighting, line numbers or controls). Useful for ASCII / Unicode box-drawing diagrams. See [Code Blocks](/docs/code-blocks#raw-languages).codeBlockMaxHeight?number | string400Max height for fenced code blocks. Numbers are treated as px. Strings pass through as CSS values (e.g. `50vh`). Set to `0` or `Infinity` to disable. While streaming (`isAnimating`), the block auto-scrolls to the bottom and unpins if the user scrolls up. See [Code Blocks](/docs/code-blocks#max-height).tableMaxHeight?number | string300Max height for tables. Numbers are treated as px. Strings pass through as CSS values (e.g. `50vh`). Set to `0` or `Infinity` to disable. While streaming (`isAnimating`), the table body auto-scrolls to the bottom and unpins if the user scrolls up. See [GitHub Flavored Markdown](/docs/gfm#max-height).animated?boolean | AnimateOptionsEnable character-by-character animation for streaming content. See [Animation](/docs/animation).linkSafety?LinkSafetyConfig{ enabled: true }Configure link safety modals for external URLs. See [Link Safety](/docs/link-safety).portal?HTMLElement | null | (() => HTMLElement | null)document.bodyDOM node (or getter) used as the portal target for built-in overlays. Useful for micro-frontends and scoped or prefixed CSS.plugins?PluginConfigPlugin configuration for math, mermaid, code highlighting, and CJK support. See [Plugins](/docs/plugins).icons?Partial<IconMap>Custom icons to override the defaults used in controls. See the IconMap interface for available keys.translations?Partial<StreamdownTranslations>Override default English labels for controls and modals. See [Internationalization](/docs/internationalization).caret?"block" | "circle"Show a caret indicator at the end of streaming content. See [Carets](/docs/carets).onAnimationStart?() => voidCalled when isAnimating transitions from false to true. Suppressed in static mode. Memoize with useCallback. See [Animation](/docs/animation).onAnimationEnd?() => voidCalled when isAnimating transitions from true to false. Suppressed in static mode. Memoize with useCallback. See [Animation](/docs/animation). Portal Target By default, Mermaid fullscreen, table fullscreen, and the built-in link safety modal render into document.body. Use portal to keep these overlays inside a micro-frontend or another subtree that provides scoped CSS, prefixed Tailwind utilities, or a specific stacking context. app/page.tsxconst portalRef = useRef<HTMLDivElement>(null); return ( <div className="my-app"> <div ref={portalRef} /> <Streamdown portal={() => portalRef.current}>{markdown}</Streamdown> </div> ); The getter form is useful when the portal element is assigned after the first render. Returning null falls back to document.body. A custom linkSafety.renderModal controls its own placement and is not moved by this prop. Like urlTransform and allowElement, portal is an initializing prop: swapping it for a different target alone does not re-render, so prefer the getter form — it is resolved each time an overlay opens. Mermaid Options The mermaid prop accepts an object with the following properties: PropTypeDescriptionconfig?MermaidConfigCustom configuration for Mermaid diagramserrorComponent?React.ComponentType<MermaidErrorComponentProps>Custom React component for handling Mermaid rendering errors Element Filtering Props These props match the react-markdown API, making Streamdown a drop-in replacement. PropTypeDefaultDescriptionallowedElements?string[]Tag names to allow (all others are removed). Cannot combine with disallowedElements.disallowedElements?string[][]Tag names to disallow (all others are kept). Cannot combine with allowedElements.allowElement?(element: Element, index: number, parent: Parent | undefined) => booleanCustom filter function called for each element. Return false to remove. Applied after allowedElements/disallowedElements.unwrapDisallowed?booleanfalseWhen true, disallowed elements are replaced by their children instead of being removed entirely.skipHtml?booleanfalseIgnore raw HTML in Markdown completely (removes raw HTML nodes from the tree).urlTransform?(url: string, key: string, node: Element) => string | null | undefineddefaultUrlTransformTransform all URLs in the Markdown (links, images, etc). Return an empty string to remove the URL. Defaults to defaultUrlTransform (passthrough). URL security is handled by rehype-sanitize and rehype-harden. Element filtering example app/page.tsx// Only allow paragraphs, links, and emphasis <Streamdown allowedElements={["p", "a", "em"]}> {markdown} </Streamdown> // Remove images but keep everything else <Streamdown disallowedElements={["img"]}> {markdown} </Streamdown> // Remove images but keep their alt text <Streamdown disallowedElements={["img"]} unwrapDisallowed> {markdown} </Streamdown> // Custom filter: remove all h3+ headings <Streamdown allowElement={(element) => !["h3", "h4", "h5", "h6"].includes(element.tagName) } > {markdown} </Streamdown> URL transform example app/page.tsximport { Streamdown