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.
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 blocksOne 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.
| Component | Web | Native |
|---|---|---|
| Markdown | Yes | Yes |
| Editor | Yes | Soon |
| Tables | Yes | Yes |
Links through your router#
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.
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#
| Syntax | Drawn as |
|---|---|
# to ###### headings, and underlined (setext) ones | Headings 1 to 6 |
| Paragraphs, hard line breaks | Paragraphs |
-, *, + and numbered lists, nested by indentation | Lists, numbered from their first item |
- [ ] and - [x] task items | A read-only checkbox; done items struck |
> quotes | A muted block behind a bar |
| Fenced and indented code | A code panel like Syntax Highlight's |
---, ***, ___ | A divider |
| GitHub tables | A table, aligned per column |
| An image alone on its line | An image |
*em*, **strong**, ~~strike~~, `code`, links, autolinks | Inline formatting |
| Frontmatter | Not drawn |
| Anything else | Its source, monospace and muted |
API Reference#
Markdown#
All other props go to the root <div>.
| Prop | Type | Default |
|---|---|---|
children | string | required |
size | "sm" | "default" | "lg" | "default" |
components | { a?: ComponentType, img?: ComponentType } | - |
syntax | MarkdownSyntax[] | - |
Accessibility#
- It renders semantic HTML: headings, lists,
blockquote,pre,tablewith 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.