React Native · Components
Markdown
Renders Markdown text safely; designed for streaming text like AI responses.
2 exports
Live example
The preview runs in the browser with the web component; the native component takes the same props and looks the same on iOS and Android.
Preview
Code
Events
- Events appear here when you interact with the preview.
Import
Markdown
componentRenders Markdown text safely; designed for streaming text like AI responses. The same parser as Markdown on web (@yasinsensoy/core) and the same typography as RichTextView.
- Streaming friendly: Text is split into top-level blocks; unchanged blocks are not re-parsed or re-rendered. Each new chunk updates only the last block.
- No flicker: While
streaming, an unclosed**bold, a half link[text](htt, a lone#or-is completed/hidden temporarily. A blinking cursor is drawn at the end. - GFM: Headings, lists (nested, numbered, task lists), quotes, code blocks (
CodeBlock), tables (alignment, horizontal scroll), links, bare URLs,~~strikethrough~~. - Safe: HTML is not executed, no WebView; unsafe addresses like
javascript:are dropped.
Examples
MarkdownProps
interfaceProps of the Markdown component.
| Name | Type | Default | Description |
|---|---|---|---|
children | string | null | undefined | Markdown text to show. While streaming the new text is given on every chunk. | |
streaming? | boolean | false | Is text still arriving (while an AI response streams)? While true the last block is completed temporarily (an unclosed **, a half link or a lone # do not show on screen) and a blinking cursor is drawn at the end. |
onLinkPress? | (url: string) => void | Called when a link is pressed. If omitted a safe address opens in the system. | |
onMentionPress? | (mention: RichTextMention) => void | Called when a mention ([@Name](mention:id)) is pressed. The counterpart of mentionHref on web. | |
codeLineNumbers? | boolean | false | Line numbers in code blocks. |
fontSize? | number | 15 | Body font size (pixels; scales with the device). |
empty? | ReactNode | Element shown when the text is empty. | |
style? | StyleProp<ViewStyle> | Container style. | |
testID? | string | Test id. |