# MarkdownViewer

> Render Markdown with your theme’s typography: GitHub tables, task lists, highlighted code blocks and heading links.

Status: beta. Category: Viewers.

```ts
import { MarkdownViewer } from '@glyphui/viewers/markdown'
```

Exports: `MarkdownViewer`, `markdownViewerStyles`, `slugify`.

## Notes

- Install the optional peer dependencies first: npm install react-markdown remark-gfm shiki.
- Safe by default: raw HTML in the Markdown shows as text. If you need HTML, add rehype-raw to rehypePlugins and rehype-sanitize after it.
- Code blocks render with CodeViewer, so they follow your theme too.

## MarkdownViewer props

| Prop | Type | Default | Description |
|---|---|---|---|
| `className` | `string` |  |  |
| `components` | `Components` |  | Override how elements render, as in react-markdown. |
| `content` | `string` |  | Markdown text. |
| `headingAnchors` | `boolean` |  | Adds `#` links to headings so readers can share them. Default true. |
| `rehypePlugins` | `PluggableList \| null` |  | Extra rehype plugins. Raw HTML in the Markdown is never rendered unless you add `rehype-raw` here, and then you should add `rehype-sanitize` after it. |
| `source` | `ViewerSource` |  | A Markdown file to load instead: a URL, a File/Blob, or bytes. |

## Example: A README

Hover a heading for its link.

```tsx
import { MarkdownViewer } from '@glyphui/viewers/markdown'
import { fixture } from '../../../lib/fixtures'

export default function Example() {
  return <MarkdownViewer source={fixture('README.md')} className="w-full max-w-2xl" />
}
```

Live page: https://glyphui.xyz/components/markdown-viewer
