This component's API and documentation are under review and may change. Use with caution in production.
Creates component mappings for react-markdown and MDX using Kookie UI components for consistent styling. Provides styled headings, paragraphs, code blocks, lists, tables, and more.
Use this utility to render markdown content with Kookie design system typography and spacing. Works with both dynamic markdown (react-markdown) and static MDX files.
Installation
shellUsage
With MDX
Create an mdx-components.tsx file at your project root:
tsxWrap your MDX content with the kb-markdown class:
tsxWith react-markdown
tsxOptions
Spacing
Use the spacing option to control density.
Spacious (Default)
Best for documentation, articles, and long-form content where readability is key.
tsxCompact
Best for chat interfaces, streaming responses, and dense UI where space is limited.
tsxCode Blocks
Code blocks use the CodeBlock component with syntax highlighting via Shiki.
tsxCustom Images
Pass a custom image component for Next.js Image optimization:
tsxContainer Requirement
The components use margins for spacing between elements. To prevent margin collapse, wrap your markdown content with the kb-markdown class:
tsxThis class applies display: flex; flex-direction: column; which prevents margin collapse. Required for both MDX and react-markdown usage.
Supported Elements
With StreamingMarkdown
For AI streaming responses, use StreamingMarkdown which handles the flex container internally:
tsxSee the Streaming Markdown documentation for details.