Markdown

Render AI responses with rich markdown, memoized streaming blocks, and optional Streamdown rendering.

Usage

Namespace UIKit AI Markdown

This component uses react-markdown with block-level memoization for streaming performance.

Features

  • Headings, lists, and links
  • Inline code snippets
  • Fenced code blocks with Shiki highlighting
tsx
<ChatMessage.Assistant>
  <ChatMessage.Avatar alt="Assistant" fallback="AI" show />
  <ChatMessage.Body>
    <ChatMessage.Content>
      <Markdown>{response}</Markdown>
    </ChatMessage.Content>
  </ChatMessage.Body>
</ChatMessage.Assistant>

AI responses can include rich formatting without coupling to any SDK.

"use client";

// oxlint-disable-next-line import/no-unassigned-import
import "streamdown/styles.css";
import { Markdown } from "@thenamespace/uikit";

Use Markdown for AI responses that need headings, lists, inline code, and fenced code blocks with Namespace UIKit styling.

Streaming

"use client";

import { useEffect, useState } from "react";

import { Streamdown } from "streamdown";

The built-in Markdown component splits content into memoized blocks so token updates only re-render the blocks that changed.

With Streamdown

"use client";

import { useEffect, useState } from "react";

import { Streamdown } from "streamdown";

Use Streamdown when you want incomplete markdown repair, streaming animation, and a caret while the assistant response is still being generated.

import { Streamdown } from "streamdown";
import "streamdown/styles.css";

<Streamdown animated caret="block" isAnimating={isStreaming}>
  {response}
</Streamdown>;

Anatomy

import { Markdown } from "@thenamespace/uikit";

<Markdown>{response}</Markdown>;

CSS Classes

Base Classes

  • .markdown - Root markdown content wrapper
  • .markdown__block - Memoized block wrapper for each parsed markdown block

Element Classes

  • .markdown__inline-code - Inline code styling

API Reference

Markdown

The root component. Renders markdown content with Namespace UIKit typography and code block styling.

PropTypeDefaultDescription
childrenstring-Markdown content to render
componentsPartial<Components>-Custom react-markdown component overrides
idstringgeneratedStable id seed used for memoized block keys
classNamestring-Additional CSS class

Also supports all native div HTML attributes.