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.
- Domaine
- Conversation et IA
- Niveau de support
- Taille
- 2.5 kB gzip, budget 17.0 kB
- Qui l'utilise
- 6 fichiers des produits et sites en production l'importent (Sovkora : 2) Compté dans l'inventaire daté du 2026-11-23.
import { Markdown, parseSource, healStreaming } from "@krizaka/ui/markdown";Web et mobile — le même composant pour React et React Native. Bêta : son API peut encore changer à une version mineure.
Pourquoi il est là. Used by Sovkora.
Quand l’utiliser
- 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.
Quand ne pas l’utiliser
- For MDX with embedded application components: keep the host's MDX pipeline.
- For one sample of code on a page.À la place : Code block
- For a few words with a bold part: write the JSX.
Installation
Installer
npm install @krizaka/ui @krizaka/tailwind @krizaka/tokens tailwindcssStyles
@import "tailwindcss";
@import "@krizaka/tailwind";
@import "@krizaka/ui/tailwind.css";Importer
import { Markdown, parseSource, healStreaming } from "@krizaka/ui/markdown";Exemples
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 | Défaut | Description |
|---|---|---|---|
childrenrequis | 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. |
Accessibilité
- 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.
Clavier
| Touches | Action |
|---|---|
| Tab | Moves through the links, table regions and code blocks. |
| ArrowLeft / ArrowRight | Scrolls the focused table region or code block sideways. |
Bonnes pratiques
- 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.
Composants liés
Générée depuis le code de @krizaka/ui 5.3.4 : son meta.ts, ses exemples et ses types.Modifier cette documentation sur GitHub