Markstream Custom Components
Overview
Customize specific Markstream nodes or trusted custom tags without replacing the parser or leaking global renderer state. Read references/patterns.md first.
When to Use
Use to replace built-ins such as image, link, code_block, mermaid, or inline_code; render trusted tags such as thinking; or scope overrides to one renderer or app. Use parser transforms only when token or AST reshaping is required.
Workflow
Before changing dependencies or source files, inspect the existing package manager and project conventions, preview the intended edits, and obtain explicit user approval.
- Classify the change as a built-in override, trusted tag, or parser transform.
- Prefer scoped mappings. Vue, Vue 2, Svelte, and Angular can use
setCustomComponents(customId, mapping); Svelte and Angular can also pass renderer-local maps.
- In React, prefer
streamingComponents for parser-backed nodes and htmlComponents for sanitized attributes plus children.
- Start with leaf nodes before containers that must preserve children.
- For trusted tag bodies containing Markdown, use a nested renderer with the same allowlist. Do not add a second smooth-streaming loop.
- Preserve node/loading props, identity keys, scope IDs, theme state, and preview-height estimates for async diagrams.
- Remove temporary scoped registrations on cleanup and validate repeated and nested tags.
Example
import MarkdownRender, {
type NodeComponentProps,
setCustomComponents,
} from 'markstream-react'
import 'markstream-react/index.css'
function ThinkingNode({ node }: NodeComponentProps<any>) {
return <details><summary>Thinking</summary>{node.content}</details>
}
setCustomComponents('assistant-panel', { thinking: ThinkingNode })
export function Answer({ markdown }: { markdown: string }) {
return (
<MarkdownRender
content={markdown}
customId="assistant-panel"
customHtmlTags={['thinking']}
htmlPolicy="safe"
/>
)
}
Limitations
- Component overrides cannot reproduce arbitrary remark/rehype transforms.
- Container overrides require careful child rendering and accessibility review.
- Framework registration APIs are not interchangeable.
Security & Safety Notes
Treat custom HTML-like tags as trusted input only. Keep safe HTML enabled and do not pass unsanitized attributes into host components.
1---2name: markstream-custom-components3description: "Override Markstream node renderers and add trusted custom tags across Vue, React, Svelte, and Angular using scoped or renderer-local mappings."4category: frontend5risk: critical6source: https://github.com/Simon-He95/markstream-vue/tree/main/.agents/skills/markstream-custom-components7source_repo: Simon-He95/markstream-vue8source_type: official9date_added: "2026-07-21"10author: Simon-He9511tags: [markdown, components, vue, react, svelte, angular]12tools: [claude, cursor, gemini, codex]13license: MIT14license_source: https://github.com/Simon-He95/markstream-vue/blob/main/license15metadata:16 source: https://skillmd.com/skills/mhassan0000/markstream-custom-components17---1819# Markstream Custom Components2021## Overview2223Customize specific Markstream nodes or trusted custom tags without replacing the parser or leaking global renderer state. Read [references/patterns.md](references/patterns.md) first.2425## When to Use2627Use to replace built-ins such as `image`, `link`, `code_block`, `mermaid`, or `inline_code`; render trusted tags such as `thinking`; or scope overrides to one renderer or app. Use parser transforms only when token or AST reshaping is required.2829## Workflow3031Before changing dependencies or source files, inspect the existing package manager and project conventions, preview the intended edits, and obtain explicit user approval.32331. Classify the change as a built-in override, trusted tag, or parser transform.342. Prefer scoped mappings. Vue, Vue 2, Svelte, and Angular can use `setCustomComponents(customId, mapping)`; Svelte and Angular can also pass renderer-local maps.353. In React, prefer `streamingComponents` for parser-backed nodes and `htmlComponents` for sanitized attributes plus children.364. Start with leaf nodes before containers that must preserve children.375. For trusted tag bodies containing Markdown, use a nested renderer with the same allowlist. Do not add a second smooth-streaming loop.386. Preserve node/loading props, identity keys, scope IDs, theme state, and preview-height estimates for async diagrams.397. Remove temporary scoped registrations on cleanup and validate repeated and nested tags.4041## Example4243```tsx44import MarkdownRender, {45 type NodeComponentProps,46 setCustomComponents,47} from 'markstream-react'48import 'markstream-react/index.css'4950function ThinkingNode({ node }: NodeComponentProps<any>) {51 return <details><summary>Thinking</summary>{node.content}</details>52}5354setCustomComponents('assistant-panel', { thinking: ThinkingNode })5556export function Answer({ markdown }: { markdown: string }) {57 return (58 <MarkdownRender59 content={markdown}60 customId="assistant-panel"61 customHtmlTags={['thinking']}62 htmlPolicy="safe"63 />64 )65}66```6768## Limitations6970- Component overrides cannot reproduce arbitrary remark/rehype transforms.71- Container overrides require careful child rendering and accessibility review.72- Framework registration APIs are not interchangeable.7374## Security & Safety Notes7576Treat custom HTML-like tags as trusted input only. Keep safe HTML enabled and do not pass unsanitized attributes into host components.