Skip to Content
docscn

MDX components

The components for Fumadocs MDX content: code blocks, headings, images, tables, cards and callouts.

Installation

npx shadcn@latest add @docscn/mdx

Usage

Spread defaultMdxComponents into your MDX components:

components/mdx.tsx
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:

KeyRenders
preCodeBlock for Shiki output
CodeBlockTabs, CodeBlockTabsList, CodeBlockTabsTrigger, CodeBlockTabCode tabs from tab="..." code blocks and ```npm blocks
h1–h6Heading with anchor links
aFumadocs Core's Link (Next.js Link for internal links)
imgNext.js Image
tableA horizontally scrollable table
Card, CardsCards
Callout, CalloutContainer, CalloutTitle, CalloutDescriptionCallouts

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.

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) })} />