Skip to content

Markdown

@astryxdesign/core v0.7.1 · Markdown

Props ​

NameTypeDefaultDescription
contentstring—Markdown source. When omitted, text in the default slot is used.
contentAlign'start' | 'center''start'Horizontal alignment of the prose measure when contentWidth is set.
contentWidthnumber | string—Maximum width of prose. A number is pixels. Tables and code blocks still fill the container.
componentsMarkdownComponents—Replaces the renderer for a node kind. Keys: blockquote, code, heading, hr, image, inlineCode, link, list, paragraph, table.
density'default' | 'compact''default'compact tightens the space between blocks.
display'block' | 'inline''block'inline renders the source as phrasing content inside a span.
headingLevelStart1 | 2 | 3 | 4 | 5 | 61The heading level a markdown # maps to. Deeper headings shift with it and stop at h6.
isStreamingbooleanfalseRe-parses only the last unfinished block and fades in new text. It does not reveal characters. For that, pass the result of useStreamingText as content.
onLinkClick(href: string, event: MouseEvent) => void | false—Called when a link is activated. Return false to cancel navigation.
pluginsMarkdownPlugin[]—Document plugins. They can replace the tree and draw their own extension nodes.
inlinePluginsMarkdownInlinePlugin[]—Match ordinary text. Inline code and fenced code are skipped.
autolink'gfm'—When set to gfm, bare URLs, www. hosts, and bare emails become links.
citationStyle'label' | 'number''label'Whether a citation chip shows the source title or a numbered badge.
sourcesRecord<string, MarkdownSource>—Citation sources by id. A matching [id] or 【id】 renders as a chip.

Slots ​

NameDescription
defaultText used as the Markdown source when content is omitted.

Expose ​

NameTypeDescription
elementHTMLElement | nullThe root element.

Composable ​

useStreamingText(targetText, isStreaming?, options?) turns a growing string into a steady reveal. options.speed is natural, fast, or instant. When streaming is off, or the user prefers reduced motion, the full source is returned.

Character smoothing stays in this composable. Pass its result to Markdown as content, and set isStreaming for block parsing and the fade. Do not wrap that result in useStreamingText again.

Native attributes ​

A block root is a <div role="document">. An inline root is a <span>.

The following are passed to the root:

  • HTML attributes.
  • aria-* attributes.
  • data-* attributes.
  • class.
  • style.
  • Native event listeners.

A provided role is used as given.