Markdown
A Markdown text on the tokens — headings, lists and tasks, quotes, tables, links, images, footnotes, fenced code in CodeBlock — parsed by TanStack Markdown, safe by default (raw HTML is never rendered), with a streaming mode for a text that arrives in pieces: an AI answer. React Native draws the same AST in Text and View.
- Domain
- Conversation & AI
- Support level
- Size
- 2.5 kB gzip, budget 17.0 kB
- Who uses it
- 6 files of the live products and sites import it (Sovkora: 2) Counted in the dated inventory of 2026-11-23.
import { Markdown, parseSource, healStreaming } from "@krizaka/ui/markdown";Web and mobile — the same component for React and React Native. Beta: its API may still change in a minor version.
Why it is here. Used by Sovkora.
When to use
- An AI answer, a message, a release note, a description written by a person or a model.
- A text that arrives in pieces (
streaming): the unfinished end is closed, so no**or half a link ever shows. - Content that comes from a user or a model, which must never run HTML.
- Product documentation and generated references with wide tables of identifiers, without custom rendering components.
When not to use
- For MDX with embedded application components: keep the host's MDX pipeline.
- For one sample of code on a page.Use instead: Code block
- For a few words with a bold part: write the JSX.
Installation
Install
npm install @krizaka/ui @krizaka/tailwind @krizaka/tokens tailwindcssStyles
@import "tailwindcss";
@import "@krizaka/tailwind";
@import "@krizaka/ui/tailwind.css";Import
import { Markdown, parseSource, healStreaming } from "@krizaka/ui/markdown";Examples
A document
A heading, a list, a table and a titled code block.
An AI answer arriving
streaming: the end of the text is closed at every cut, with a caret; the button plays it from the start.
A generated reference on a phone
Nine columns of long identifiers, a host-labelled generated chip, long prose and scrolling code.
Props
A Markdown text on the tokens: headings, paragraphs, lists (and tasks), quotes, tables, code, links, images, footnotes.
| Prop | Type | Default | Description |
|---|---|---|---|
childrenrequired | string | — | The Markdown source. |
codeLabels | { copy: string; copied: string; } | — | The words of the copy button of the code blocks, passed translated. Without them a code block has no copy button. |
generated | boolean | — | Marks a generated document with a quiet chip, when generatedLabel is supplied. |
generatedLabel | string | — | The chip's words, passed translated by the host; no chip is rendered without them. |
headingIds | boolean | — | Gives every heading an id, for #section links. |
linkAs | ElementType<DetailedHTMLProps<AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>, keyof IntrinsicElements> | — | Your router's link (Next's Link) for the links that stay on the site (/docs, #section); the others are plain a. |
streaming | boolean | — | The text is still arriving: the unfinished end is closed and a caret marks the end. |
Accessibility
- The structure is real elements: headings in order, lists, a table with column headers,
figureandfigcaptionfor a titled code block. - A task list is disabled checkboxes inside their labels, so each item reads as done or not done.
- While
streaming, the root carriesaria-busy; the caret is decorative (a CSS pseudo-element) and still under reduced motion. - Raw HTML in the source is shown as text, and links or images with an executable address (
javascript:,data:) are dropped. - Each table region is named from its column headers; the generated chip is a static label, not a button.
Keyboard
| Keys | Action |
|---|---|
| Tab | Moves through the links, table regions and code blocks. |
| ArrowLeft / ArrowRight | Scrolls the focused table region or code block sideways. |
Best practices
- Pass the words of the code blocks' copy button with
codeLabels(translated); without them a block has no button. - Give your router's link to
linkAs: the links that stay on the site go through it, the others open as plain links withrel="noopener noreferrer". - Set
streamingwhile the text is arriving and drop it when it is complete: the caret goes away and the text is read as written. - Write the source in the user's language; the component adds no words of its own.
- On a phone, give
onLinkPressto open a link in your app's browser; the default opens http(s) links with the system. - Pass
generatedand the translatedgeneratedLabelto mark generated content; without the label no chip is shown. The host reads front matter and passes itsgenerated: truevalue as the prop. - Tables scroll within a focusable frame with edge shadows. Inline code in cells never breaks, including at hyphens; the first column fits its content and other cells wrap between items. Prose breaks a long word only at overflow; fenced code scrolls without wrapping.
Related components
Generated from the code of @krizaka/ui 5.3.4: its meta.ts, its examples and its types.Edit this documentation on GitHub