Search documentation

Search pages, components, blocks, styles and colours.

Get started
Skip to content

Markdown

PreviousNext

Markdown drawn with the document typography the Editor uses.

Release notes

Fabricator 0.6 brings a Markdown preview and an editor that writes it back. Read the changelog for the rest.

  • Headings, lists and inline code
  • Tables and task lists
    • Nested items keep their place

Unedited files save byte for byte.

TypeScript
import { Markdown } from "@/components/ui/markdown"
  • Parser
  • Native editor

Give it a Markdown string and it draws headings, lists and tasks, quotes, code, tables, images and links in the document type role the Editor uses, so a preview looks like what was written. It has its own parser with no dependencies, and anything the parser doesn't model (HTML, footnotes, math) shows as its source instead of disappearing.

Markdown is part of the Fabricator style. It renders plain HTML with no hooks, so the same component ships for every base and works in Server Components, and the same parser runs in the React Native version.

Installation

bunx --bun fabricator-ui@latest add markdown

Usage

import { Markdown } from "@/components/ui/markdown"
<Markdown>{note.body}</Markdown>

Composition

Markdown    parses the string and draws its blocks

One part. To change how links or images render, pass components; for the parsed document itself, parseMarkdown in lib/markdown-parse.ts returns the blocks and their runs.

Examples

Sizes

size picks the document type role: sm (14px, for comments, chat and panels), default (16px) and lg (18px, for long-form reading). Headings, code and spacing scale with it.

Weekly sync

Ship the editor preview, then review native input on Friday.

Weekly sync

Ship the editor preview, then review native input on Friday.

Weekly sync

Ship the editor preview, then review native input on Friday.

Tables

GitHub tables, with their column alignment. Wide tables scroll sideways in their own box.

ComponentWebNative
MarkdownYesYes
EditorYesSoon
TablesYesYes

components.a replaces the link element, for a router's link or to open external links in a new tab. components.img does the same for images.

Links can go through your router: open Settings or the docs.

Source it keeps

HTML blocks, inline HTML, footnotes, reference links and math aren't modelled yet. They show as their source, quiet and monospace, so nothing in a document is hidden.

Anything the parser doesn't model stays visible as its source:

<details>
<summary>Release checklist</summary>

Run the corpus.

</details>

A footnote reference[^1] and inline <kbd>HTML</kbd> too.

[^1]: Footnotes arrive in a later release.

Supported syntax

SyntaxDrawn as
# to ###### headings, and underlined (setext) onesHeadings 1 to 6
Paragraphs, hard line breaksParagraphs
-, *, + and numbered lists, nested by indentationLists, numbered from their first item
- [ ] and - [x] task itemsA read-only checkbox; done items struck
> quotesA muted block behind a bar
Fenced and indented codeA code panel like Syntax Highlight's
---, ***, ___A divider
GitHub tablesA table, aligned per column
An image alone on its lineAn image
*em*, **strong**, ~~strike~~, `code`, links, autolinksInline formatting
FrontmatterNot drawn
Anything elseIts source, monospace and muted

API Reference

Markdown

All other props go to the root <div>.

PropTypeDefault
childrenstringrequired
size"sm" | "default" | "lg""default"
components{ a?: ComponentType, img?: ComponentType }-
syntaxMarkdownSyntax[]-

Accessibility

  • It renders semantic HTML: headings, lists, blockquote, pre, table with a header row, so screen readers navigate it as a document.
  • Task checkboxes are disabled inputs labelled "Done" or "Not done".
  • Images take their alt text from the Markdown; write it there.
  • Links keep their own text; a link with no text reads its address.