Markdown rendering with assistant-ui

VerifiedSafe

Render and customize assistant message text as markdown in assistant-ui, with syntax highlighting, LaTeX math, and Mermaid diagrams.

Sby Skills Guide Bot
DevelopmentIntermediate
8/29/2026
Claude CodeCursorWindsurfCopilotCodex
#markdown#assistant-ui#react#streaming#syntax-highlighting

Recommended for

Automated summary

Renders assistant messages as markdown in assistant-ui using MarkdownTextPrimitive, with support for syntax highlighting, KaTeX math, Mermaid diagrams, and streaming via plugins and memoized components.

Strengths

  • Provides a complete setup for markdown rendering in assistant-ui, including code highlighting, LaTeX, and Mermaid diagrams.
  • Covers both MarkdownTextPrimitive and StreamdownTextPrimitive, offering a batteries-included alternative with block streaming.
  • Includes practical gotchas for common issues like missing styles, stream-triggered Mermaid parsing, and incorrect wiring.

Limitations

  • Requires additional packages and configuration for highlighting and math; these are not bundled by default.
  • Some APIs are unstable (e.g., unstable_memoizeMarkdownComponents) and may change.
  • The skill is specific to assistant-ui and React, not applicable to other frameworks.
When to use it

Use when building an assistant chat UI in React and needing to display model output as formatted markdown with code, math, or diagrams.

When not to use it

Avoid when you need a framework-agnostic markdown renderer or when your project does not use assistant-ui.

Security analysis

Safe
Quality score92/100

The skill provides documentation and code examples for rendering markdown in assistant-ui. It does not instruct destructive, exfiltrating, or obfuscated actions. No tools are declared, and the content is purely educational/instructional for UI configuration.

No concerns found

How this analysis is made

Examples

Set up markdown rendering
Wire up MarkdownTextPrimitive in my assistant-ui app so that model responses render as markdown with GitHub-flavored markdown (remark-gfm) and syntax highlighting using react-shiki.
Add LaTeX and Mermaid support
Configure my assistant-ui markdown component to render LaTeX math with KaTeX and Mermaid diagrams, but gate the Mermaid rendering on stream completion to avoid partial diagram errors.
Fix plain text showing instead of markdown
In my assistant-ui chat, the text parts show as raw plain text instead of formatted markdown. Why? Show me the correct MessagePrimitive.Parts wiring and how to use MarkdownTextPrimitive.

name: markdown description: "Render and customize assistant message text as markdown in assistant-ui. Use when displaying model output as formatted markdown with MarkdownTextPrimitive from @assistant-ui/react-markdown wired into the MessagePrimitive.Parts text branch, configuring remarkPlugins (remark-gfm, remark-math) and rehypePlugins (rehype-katex), or memoizing components with unstable_memoizeMarkdownComponents. Covers code-block syntax highlighting via react-shiki or react-syntax-highlighter registered as SyntaxHighlighter in components/componentsByLanguage, LaTeX math rendering with KaTeX, Mermaid diagrams gated on stream completion, custom math delimiters via preprocess, and the StreamdownTextPrimitive alternative from @assistant-ui/react-streamdown with built-in Shiki/KaTeX/Mermaid and block streaming. For general chat UI composition route to primitives." license: MIT

assistant-ui Markdown

Always consult assistant-ui.com/llms.txt for the latest API.

Render and customize assistant message text as markdown with MarkdownTextPrimitive from @assistant-ui/react-markdown, wired into the MessagePrimitive.Parts text branch.

References

Orientation

MarkdownTextPrimitive renders one text part as markdown. The registry component (npx assistant-ui@latest add markdown-text) generates components/assistant-ui/markdown-text.tsx, which exports a memoized MarkdownText built on the primitive plus a defaultComponents map from unstable_memoizeMarkdownComponents. Render MarkdownText from the text branch of MessagePrimitive.Parts.

import "@assistant-ui/react-markdown/styles/dot.css";
import { MarkdownTextPrimitive } from "@assistant-ui/react-markdown";
import { MessagePrimitive } from "@assistant-ui/react";
import remarkGfm from "remark-gfm";
import { memo } from "react";

const MarkdownTextImpl = () => (
  <MarkdownTextPrimitive
    remarkPlugins={[remarkGfm]}
    className="aui-md"
    components={defaultComponents}
  />
);

export const MarkdownText = memo(MarkdownTextImpl);

<MessagePrimitive.Parts>
  {({ part }) => (part.type === "text" ? <MarkdownText /> : null)}
</MessagePrimitive.Parts>;

Add highlighting, math, or diagrams by extending the same primitive: rehypePlugins for KaTeX, componentsByLanguage for a per-language SyntaxHighlighter (Mermaid, diff), and preprocess to normalize raw text before parsing. See the references for each. For a batteries-included alternative with built-in Shiki, KaTeX, Mermaid, and block streaming, swap in StreamdownTextPrimitive from @assistant-ui/react-streamdown.

Common Gotchas

  • Nothing renders / plain text shows. The text branch must return MarkdownText; returning <p>{part.text}</p> bypasses markdown entirely.
  • No syntax highlighting. Highlighting is not bundled. Register a SyntaxHighlighter in defaultComponents (react-shiki recommended) per the syntax-highlighting reference.
  • KaTeX has no styling. Import katex/dist/katex.min.css once at the app root; rehypeKatex only emits markup.
  • Mermaid parses partial diagrams while streaming. Gate rendering on stream completion (the reference uses useAuiState to detect the closing fence) instead of rendering every delta.
  • Memoization export name. The package exports unstable_memoizeMarkdownComponents; the generated file aliases it to memoizeMarkdownComponents.
  • Unstyled by default. The aui-md class and styles/dot.css provide base styling; add your own Tailwind/CSS otherwise.

Related Skills

  • primitives -- general UI composition (ThreadPrimitive, ComposerPrimitive, MessagePrimitive.Parts) for assembling the message and the rest of the chat surface around the markdown text branch.

From the file to a first result

The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.

View the source and supporting files

This download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.

1. Download the file

Download SKILL.md

From the root of a test project, save the file as .skill-downloads/markdown-rendering-with-assistant-ui-mte1lgth/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.

Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.

mkdir -p '.skill-downloads/markdown-rendering-with-assistant-ui-mte1lgth' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/markdown-rendering-with-assistant-ui-mte1lgth/download' --output '.skill-downloads/markdown-rendering-with-assistant-ui-mte1lgth/SKILL.md.part' && mv '.skill-downloads/markdown-rendering-with-assistant-ui-mte1lgth/SKILL.md.part' '.skill-downloads/markdown-rendering-with-assistant-ui-mte1lgth/SKILL.md'

2. Check prerequisites

Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.

No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.

The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.

3. Load the skill

After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.

Claude Code
test -f '.skill-downloads/markdown-rendering-with-assistant-ui-mte1lgth/SKILL.md' && test -s '.skill-downloads/markdown-rendering-with-assistant-ui-mte1lgth/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/markdown' && cp -R '.skill-downloads/markdown-rendering-with-assistant-ui-mte1lgth' '.claude/skills/markdown'

Cursor
test -f '.skill-downloads/markdown-rendering-with-assistant-ui-mte1lgth/SKILL.md' && test -s '.skill-downloads/markdown-rendering-with-assistant-ui-mte1lgth/SKILL.md' && mkdir -p '.cursor/skills' && test ! -e '.cursor/skills/markdown' && cp -R '.skill-downloads/markdown-rendering-with-assistant-ui-mte1lgth' '.cursor/skills/markdown'

Codex
test -f '.skill-downloads/markdown-rendering-with-assistant-ui-mte1lgth/SKILL.md' && test -s '.skill-downloads/markdown-rendering-with-assistant-ui-mte1lgth/SKILL.md' && mkdir -p '.agents/skills' && test ! -e '.agents/skills/markdown' && cp -R '.skill-downloads/markdown-rendering-with-assistant-ui-mte1lgth' '.agents/skills/markdown'

OpenSkills

OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.

Official OpenSkills installation
openskills install './.skill-downloads/markdown-rendering-with-assistant-ui-mte1lgth'

openskills read 'markdown-rendering-with-assistant-ui-mte1lgth'

Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.

For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.

openskills sync

Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.

4. Try a first task

Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:

Read .skill-downloads/markdown-rendering-with-assistant-ui-mte1lgth/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.

Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.

Related skills