Skip to content
mdxcn is now part of Shadcn Labs. details

mdx

withMdxcn

Wrap your MDX components once with withMdxcn. Graphs keep working even when your docs framework replaces standard tags, and ordinary Markdown alerts, quotes, shell sessions and footnotes get drawn in a frame. GitHub still shows the plain Markdown.

install

If you installed all.json, you already have it. Installed on its own, it also brings in Callout, Quote and Terminal.

command

wire

[ mdx-components.tsx ]
import { withMdxcn } from "@/registry/default/mdx/mdx"import { GraphTimeline } from "@/registry/default/graph-timeline/graph-timeline" export function useMDXComponents(components) {  return withMdxcn({ ...components, GraphTimeline })}
  1. Runs on the server. The file has no "use client"; the frames it swaps in are client components.
  2. Register the parents you use. Lists and tables inside them need no imports.

mdx-components.tsx

upgrades

Write Markdown that already looks right on GitHub. On your site, it renders as the frames below. The full list is on the grammar page.

page.mdx

[ warning ]

The CLI copies files. Edit the source.

Less, but better.

Dieter Rams
[ shell ]
pnpm dlx shadcn@latest add @mdxcn/mdx✓ 7 files written
[ footnotes ]

Footnotes

  1. SVG does not survive a README.

overrides

Most docs frameworks replace standard tags with their own components, like li with ListItem or table with Table. Graphs read their content by tag name, so a replaced li looks like an unknown component and the list comes out empty. withMdxcn labels each replacement so graphs still recognize the original tag. It also works with React Server Components, because the label is passed as a data-graph-host prop.

mdx-components.tsx

options

Every upgrade is on by default. Turn off any you'd rather style yourself.

options