Web · Components
Markdown
Renders Markdown text safely; designed for streaming text such as AI responses.
2 exports
Live example
Preview
Code
Events
- Events appear here when you interact with the preview.
Import
Renders Markdown text safely; designed for streaming text such as AI responses. Uses the same typography as RichTextView.
- Streaming friendly: The text is split into top-level blocks; unchanged blocks are not re-parsed or re-rendered. Even in a response of thousands of lines each new chunk updates only the last block.
- No flicker: While
streaming, an unclosed**bold, a half link[text](htt, a lone#or-is temporarily completed/hidden; raw markers don't flash. A blinking caret is drawn at the end. - GFM: Headings, lists (nested, numbered, task lists), quotes, code blocks (
CodeBlock: highlighting, copy), tables (alignment, horizontal scroll), links, bare URLs,~~strikethrough~~. - Safe:
dangerouslySetInnerHTMLis not used; HTML isn't executed and unsafe URLs likejavascript:are dropped. External links open withrel="noopener noreferrer nofollow".
Examples
MarkdownProps
interfaceProps of the Markdown component.
Extends: Omit<ComponentProps<"div">, "children">
| Name | Type | Default | Description |
|---|---|---|---|
children | string | null | undefined | Markdown text to show. While streaming, a new one is given with each chunk. | |
streaming? | boolean | false | Is the text still arriving (while an AI response streams)? While true, the last block is temporarily completed (an unclosed **, a half link, a lone # don't show on screen) and a blinking caret is drawn at the end. |
linkTarget? | string | "_blank" | Target of links. "_blank" opens external links in a new tab. |
mentionHref? | (mention: RichTextMention) => string | undefined | Turns a mention ([@Name](mention:id)) into a link. | |
codeLineNumbers? | boolean | false | Line numbers in code blocks. |
empty? | ReactNode | Element shown when the text is empty. |