Markdown
Markdown rendering for AI answers. Handles streaming without half-typed syntax, tables you can copy and inline citations.
- Category
- AI
- Components used
- 4
- Files
- 4
- Usage examples
- 2
- Access
- HextaUI Pro (55 blocks)
- Source updated
- Counted in
- UI component usage study
Part of HextaUI Pro, all 55 blocks, $79 one-time, Compare plans
Models answer in Markdown, and they write it a token at a time. A plain renderer flashes raw asterisks, half-built tables and unclosed code fences while it streams. Markdown completes unfinished syntax as it goes and paces the text like the Streaming block, so formatting appears in place.
Each element is built from the rest of HextaUI. Code fences become Code Blocks, GitHub callouts like [!NOTE] use Alert, task lists use read-only Checkboxes, and tables scroll sideways with a menu to copy them as Markdown or CSV. Pass sources and [1] becomes a citation chip, while marks inside code are left alone.
Headings get ids from their text, with an optional link icon to share them. Images load lazily with a placeholder and caption, footnotes link back to their mark, external links open in a new tab and say so, and text direction is detected per block. It works as well for READMEs and changelogs as for streamed answers.
Get HextaUI Pro
One payment unlocks every block, including future ones. See pricing.
Add the Pro registry to components.json
components.json Add your token
Create a token on your account page and put it in
.env.localasHEXTAUI_PRO_TOKEN.Add the block
pnpm dlx shadcn@latest add @hextaui-pro/markdown
With the AI SDK
Render each text part of a useChat message, with source-url parts as its sources. The part’s state tells Markdown when the model is still writing.
Static content
Pass a string as children for READMEs, changelogs or saved answers. Set anchors to give headings a link people can share.
Anatomy
The parts you compose, from the outside in.
| Part | Description |
|---|---|
Markdown | The renderer. Takes a string and handles pacing, parsing and every element. |
MarkdownTable | A scrollable table with the copy menu. |
MarkdownAlert | A callout for [!NOTE] and the other GitHub alert types. |
MarkdownHeading | A heading with an id and optional anchor link. |
MarkdownImage | An image with loading, error and caption states. |
| Prop | Type | Default |
|---|---|---|
textThe Markdown so far. You can pass it as children instead. | string | – |
streamingPaces the text, shows the caret and completes unfinished syntax. | boolean | false |
smoothTurn pacing off to render text exactly as received. | boolean | true |
sourcesTurns [1] into a chip for sources[0], and so on. Without sources, [1] stays plain text. | Source[] | [] |
sizeText size. Use sm in chat and base for articles. | "sm" | "base" | "sm" |
anchorsShow a link icon on headings. | boolean | false |
componentsOverride any element, such as a or img. Keep the object stable, for example outside the component, so blocks don’t remount. | Components | – |
classNameClasses for the wrapper. | string | – |
| Key | Action |
|---|---|
| Tab | Moves through links, citations, heading anchors, table copy menus and code block actions in reading order. |
| Enter | Opens a link, or the copy menu on a table. |
| ↑↓ | Moves between Copy as Markdown and Copy as CSV. |
- The wrapper is marked aria-busy while it streams, so screen readers wait for the text to settle.
- Callouts use role=note with their type as the label, instead of announcing like live alerts.
- Task list checkboxes are read-only and skipped by Tab, so they read as state rather than controls.
- External links say “opens in a new tab”, citation chips are named after their source, and heading anchors are named “Link to …”.
- Images keep their alt text, and tables keep their header cells for screen reader navigation.
- With reduced motion, the caret stops pulsing and images appear without fading.
Built with
The free HextaUI components Markdown is made from. Each one installs on its own.
Code
4 files, added to components/blocks/markdown.