Streaming Markdown
Renders markdown content with support for streaming text, making it ideal for AI-generated content or real-time updates. Handles incomplete markdown gracefully during streaming and includes block-level memoization for optimal performance.
Built with react-markdown, GitHub Flavored Markdown support, and integrated with Kookie UI components.
Installation
shellUsage
tsxProps
Options
Examples
Streaming AI Content
StreamingMarkdown handles partial markdown gracefully, making it perfect for AI responses:
tsxWith Block Memoization
For optimal performance with streaming content, enable block-level memoization using marked.lexer. Define the parser outside the component for stable references:
tsxCustom Component Overrides
Override default markdown components with custom implementations:
tsxDisable Code Block Features
Customize code block appearance:
tsxAccessibility
Streaming Markdown provides comprehensive accessibility features:
Semantic HTML
- Renders proper HTML5 semantic elements (
<h1>-<h6>,<p>,<ul>,<ol>, etc.) - Maintains proper heading hierarchy
- Uses semantic
<code>and<pre>elements
Keyboard Navigation
- Tab - Navigate between interactive elements (links, buttons)
- Enter - Activate links and copy buttons
- Space - Activate copy buttons
Screen Readers
- All links include proper ARIA labels
- Code blocks announce language when present
- Copy button announces action state
Security
- Link and image URLs are validated against allowed prefixes
- Supports
defaultOriginfor security origin validation - Sanitizes HTML content using
harden-react-markdown
Changelog
Added
- Streaming markdown support with unterminated block parsing
- Block-level memoization for performance optimization
- GitHub Flavored Markdown support
- Security hardening for links and images
- Integration with Kookie UI CodeBlock component
- Custom component override support