Command palette

@yasinsensoy/web

Web · Components

Markdown

Renders Markdown text safely; designed for streaming text such as AI responses.

2 exports

Live example

Preview

Code

import { Markdown } from "@yasinsensoy/web";

<Markdown streaming={durum === "streaming"}>{metin}</Markdown>

Events

  1. Events appear here when you interact with the preview.

Import

import { Markdown } from "@yasinsensoy/web";

Markdown

componentClient component

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: dangerouslySetInnerHTML is not used; HTML isn't executed and unsafe URLs like javascript: are dropped. External links open with rel="noopener noreferrer nofollow".
Markdown({ children, streaming, linkTarget, mentionHref, codeLineNumbers, empty, className, ...props }: MarkdownProps): JSX.Element

Examples

<Markdown>{answer}</Markdown>
<Markdown streaming={status === "streaming"}>{message.content}</Markdown>

MarkdownProps

interface

Props of the Markdown component.

Extends: Omit<ComponentProps<"div">, "children">

NameTypeDefaultDescription
childrenstring | null | undefinedMarkdown text to show. While streaming, a new one is given with each chunk.
streaming?booleanfalseIs 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 | undefinedTurns a mention ([@Name](mention:id)) into a link.
codeLineNumbers?booleanfalseLine numbers in code blocks.
empty?ReactNodeElement shown when the text is empty.