Back to Supabase

Markdown

apps/design-system/content/docs/ui-patterns/markdown.mdx

1.26.082.6 KB
Original Source

A composable react-markdown component with defaults for all standard markdown elements (headings, paragraphs, lists, blockquotes, links, images, tables, code). Customize any element via the components prop and import optional components such as Quote or Avatar. All components are lazy-loaded.

<ComponentPreview name="markdown-full-example" peekCode />

API

PropTypeDefaultDescription
childrenstring-Markdown content to render
contentstring''Deprecated: Use children instead
codeBlockbooleanfalseEnable syntax highlighting for code blocks (lazy-loaded via CodeBlock)
componentsPartial<Components>-Override or add specific markdown elements
classNamestring-CSS class for the wrapper div
remarkPluginsPluggableList[remarkGfm]Additional remark plugins (GFM is included by default)

All other react-markdown options are supported via spread props.

Customization

Override any element or add new ones via the components prop.

<ComponentPreview name="markdown-customization" peekCode />

Primitive Components

tsx
import {
  Anchor,
  Avatar,
  Blockquote,
  Code,
  CodeBlockPre,
  DefaultPre,
  Hr,
  Img,
  Paragraph,
  Quote,
  SimplePre,
  Table,
  Td,
  Th,
  Tr,
  UnorderedList,
} from 'ui-patterns/Markdown'

Headings

<ComponentPreview name="markdown-headings" />

Paragraphs

<ComponentPreview name="markdown-paragraphs" />

Lists

<ComponentPreview name="markdown-lists" /> <ComponentPreview name="markdown-links" />

Inline Code

<ComponentPreview name="markdown-inline-code" />

Blockquotes

<ComponentPreview name="markdown-blockquotes" />

Code Blocks

<ComponentPreview name="markdown-code-blocks" />

Tables

<ComponentPreview name="markdown-tables" />

Images

<ComponentPreview name="markdown-images" />

Horizontal Rules

<ComponentPreview name="markdown-horizontal-rules" />

Optional Components

Quote

<ComponentPreview name="markdown-quote-component" peekCode />

Avatar

<ComponentPreview name="markdown-avatar-component" peekCode />