Skip to Content
⭐️ Leave a star →
ComponentsMarkdown

Markdown

Headless Markdown renderer. Bring your own parser (remark / marked) — Wire UI exposes the render parts via the components map so you control every element. Pass a pre-parsed nodes tree, or content plus a parse function.

Features

Renders a normalized, mdast-compatible node tree.
Bring your own parser — pass nodes, or content + parse.
Override any node renderer through the components map.
Ships semantic HTML with zero styling out of the box.
Unknown node types fall back to rendering their children, so custom output never breaks.
Task-list items, fenced code with language hints, links, images, and more.

Example

Wire UI

A headless library with zero CSS and full control.

  • Compound components
  • data-* styling
  • Install @wire-ui/react

Style it however you like.

npm i @wire-ui/react
import { Markdown } from '@wire-ui/react' import type { MarkdownNode } from '@wire-ui/react' const nodes: MarkdownNode[] = [ { type: 'heading', depth: 2, children: [{ type: 'text', value: 'Wire UI' }] }, { type: 'paragraph', children: [{ type: 'text', value: 'A headless library.' }] }, ] <Markdown nodes={nodes} />

Styling

Markdown ships unstyled, semantic HTML. The cleanest way to style it is to override renderers through the components map — each entry receives { node, children } and returns your own element. Overrides merge over the built-ins, so you only need to supply the node types you care about.

The default renderers set a few data attributes you can also target with CSS: data-inline on inline code, data-language on fenced code, and data-task / data-checked on task-list items.

/* Default fenced-code block */ pre[data-language] code { font-family: ui-monospace, monospace; } /* Inline code */ code[data-inline] { background: #f5f5f5; padding: 0 0.25rem; } /* Task-list items */ li[data-task] { list-style: none; } li[data-checked] { text-decoration: line-through; }

Wiring a real parser

parse turns a raw string into the normalized node tree. Wrap remark (whose mdast output matches the MarkdownNode shape) or map another parser’s output onto it.

import { Markdown } from '@wire-ui/react' import { unified } from 'unified' import remarkParse from 'remark-parse' const parse = (content: string) => unified().use(remarkParse).parse(content).children <Markdown content="# Hello\n\nWorld" parse={parse} />

When content is provided without parse, the raw string is rendered as a single paragraph as a graceful fallback.

Markdown props

PropTypeDefaultDescription
nodesMarkdownNode[]Pre-parsed node tree. Provide this, or content + parse
contentstringRaw Markdown source. Parsed with parse when provided
parse(content: string) => MarkdownNode[]Turns content into normalized nodes — wrap remark / marked here
componentsMarkdownComponentsOverride the renderer used for one or more node types

Markdown also accepts all standard <div> HTML attributes (except children).

MarkdownNode

FieldTypeDescription
typeMarkdownNodeTypeNode type (heading, paragraph, text, link, …). Unknown strings fall back to rendering children
valuestringLiteral text for leaf nodes (text, inlineCode, code)
depthnumberHeading level, 1–6
urlstringDestination for link / image
titlestring | nullAdvisory title for link / image
altstringAlternate text for image
orderedbooleanWhether a list is ordered
startnumberStarting number for an ordered list
checkedboolean | nullTask-list state for a listItem (null when not a checkbox item)
langstringLanguage hint for a fenced code block
childrenMarkdownNode[]Child nodes

Component props (renderer)

Each entry in components is a component receiving these props:

PropTypeDescription
nodeMarkdownNodeThe node being rendered
childrenReactNodePre-rendered child nodes (or the leaf value)

Data attributes

AttributeElementValues
data-inlineDefault inlineCodeAlways present
data-languageDefault code <pre> / <code>The lang value (when present)
data-taskDefault task listItemPresent for checkbox items
data-checkedDefault task listItemPresent when the task is checked

These come from the built-in renderers; supply your own via components to change them.

Last updated on

MIT License © 2026 wire-ui

Markdown – Wire UI