Loading...
Loading...
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.
npx skill4agent add assistant-ui/skills markdownMarkdownTextPrimitive@assistant-ui/react-markdownMessagePrimitive.PartsMarkdownTextPrimitivenpx assistant-ui@latest add markdown-textcomponents/assistant-ui/markdown-text.tsxMarkdownTextdefaultComponentsunstable_memoizeMarkdownComponentsMarkdownTexttextMessagePrimitive.Partsimport "@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>;rehypePluginscomponentsByLanguageSyntaxHighlighterpreprocessStreamdownTextPrimitive@assistant-ui/react-streamdowntextMarkdownText<p>{part.text}</p>SyntaxHighlighterdefaultComponentskatex/dist/katex.min.cssrehypeKatexuseAuiStateunstable_memoizeMarkdownComponentsmemoizeMarkdownComponentsaui-mdstyles/dot.cssThreadPrimitiveComposerPrimitiveMessagePrimitive.Parts