MDX components
The components for Fumadocs MDX content: code blocks, headings, images, tables, cards and callouts.
Installation
npx shadcn@latest add @docscn/mdxUsage
Spread defaultMdxComponents into your MDX components:
import type { MDXComponents } from "mdx/types";
import defaultMdxComponents from "@/components/docs/mdx";
export function getMDXComponents(components?: MDXComponents) {
return {
...defaultMdxComponents,
...components,
} satisfies MDXComponents;
}It covers everything Fumadocs MDX's default preset emits:
| Key | Renders |
|---|---|
pre | CodeBlock for Shiki output |
CodeBlockTabs, CodeBlockTabsList, CodeBlockTabsTrigger, CodeBlockTab | Code tabs from tab="..." code blocks and ```npm blocks |
h1–h6 | Heading with anchor links |
a | Fumadocs Core's Link (Next.js Link for internal links) |
img | Next.js Image |
table | A horizontally scrollable table |
Card, Cards | Cards |
Callout, CalloutContainer, CalloutTitle, CalloutDescription | Callouts |
The docs block's components/mdx.tsx also adds Tabs, Steps, Accordion, Files and TypeTable, which Fumadocs UI's default components leave out. If you migrated from Fumadocs UI, import them in components/mdx.tsx the same way.
Relative links
createRelativeLink resolves links to other MDX files ([Next](./next.mdx)) to their page URLs. It works in server components only:
<MDX components={getMDXComponents({ a: createRelativeLink(source, page) })} />