Skip to Content

Markdown

Safe, GitHub-flavoured Markdown for text your app did not write.

Release 2.4

#

Invoices now export to CSV and sync with the billing API.

Fixes

#
  • Overdue badge shows the right day count
  • Refund emails use the customer locale
PlanSeatsPrice
Team10$49
Scale50$199
import { Markdown } from "@dapplelight/signet-ui/components/markdown"

const changelog = `# Release 2.4

Invoices now **export to CSV** and sync with [the billing API](https://example.com/docs).

## Fixes

- [x] Overdue badge shows the right day count
- [ ] Refund emails use the customer locale

| Plan | Seats | Price |
| ---- | ----- | ----- |
| Team | 10    | $49   |
| Scale | 50   | $199  |
`

export function Demo() {
  return <Markdown>{changelog}</Markdown>
}

Installation

npm i @dapplelight/signet-ui

Usage

import {
  Markdown,
  MarkdownToc,
  markdownToc,
} from "@dapplelight/signet-ui/components/markdown"
import { job } from "./jobs"

<Markdown>{job.description}</Markdown>

Needs the optional peers react-markdown, remark-gfm, remark-parse, unified and github-slugger.

Examples

Table of contents

Release 2.4

#

Invoices now export to CSV and sync with the billing API.

Fixes

#
  • Overdue badge shows the right day count
  • Refund emails use the customer locale
PlanSeatsPrice
Team10$49
Scale50$199
import { Markdown, MarkdownToc } from "@dapplelight/signet-ui/components/markdown"

export function Release({ changelog }: { changelog: string }) {
  return (
    <div className="flex gap-8">
      <MarkdownToc markdown={changelog} idPrefix="user-content-" />
      <Markdown>{changelog}</Markdown>
    </div>
  )
}

Images

[Quarterly revenue chart]

See the chart above.

Quarterly revenue chart

See the chart above.

import { Markdown } from "@dapplelight/signet-ui/components/markdown"

const source = "![Quarterly revenue chart](https://example.com/revenue.png)"

// Off by default: shows the alt text, fetches nothing.
<Markdown>{source}</Markdown>

// Allow only your own host.
<Markdown images={(src) => src.startsWith("https://example.com/")}>{source}</Markdown>

Without heading anchors

Shipping policy

Orders ship within 2 business days.

import { Markdown } from "@dapplelight/signet-ui/components/markdown"

<Markdown headingAnchors={false}>{"## Shipping policy\n\nOrders ship within 2 business days."}</Markdown>

API Reference

Markdown

PropTypeDefaultDescription
childrenstring-The Markdown source. Raw HTML in it is dropped.
classNamestring-Class on the wrapper.
idPrefixstring"user-content-"Prefix for heading ids. Pass the same value to MarkdownToc.
imagesboolean | ((src: string) => boolean)falsefalse shows alt text only. true allows any safe URL. A function decides per URL.
headingAnchorsbooleantrueShow a # link beside each heading.

MarkdownToc

PropTypeDefaultDescription
markdownstring-The same Markdown given to Markdown.
maxDepthnumber3Deepest heading level listed.
idPrefixstring""Must match the idPrefix of Markdown.
titlestring"On this page"Heading and accessible name of the nav.
activeIdstring-Heading id to mark current with aria-current.
classNamestring-Class on the nav.

markdownToc(markdown, options)

PropTypeDefaultDescription
maxDepthnumber3Deepest heading level returned.
idPrefixstring"user-content-"Prefix added to every id. Returns { id, text, depth }[].