---
title: "MDX components"
description: "The components for Fumadocs MDX content: code blocks, headings, images, tables, cards and callouts."
url: https://docscn.dev/docs/components/mdx
lastModified: 2026-10-09T09:13:37.000Z
---

# MDX components (/docs/components/mdx)

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

## Installation [#installation]

```npm
npx shadcn@latest add @docscn/mdx
```

## Usage [#usage]

Spread `defaultMdxComponents` into your MDX components:

```tsx title="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:

| Key                                                                          | Renders                                                      |
| ---------------------------------------------------------------------------- | ------------------------------------------------------------ |
| `pre`                                                                        | [`CodeBlock`](/docs/components/codeblock) for Shiki output   |
| `CodeBlockTabs`, `CodeBlockTabsList`, `CodeBlockTabsTrigger`, `CodeBlockTab` | Code tabs from `tab="..."` code blocks and ` ```npm ` blocks |
| `h1`–`h6`                                                                    | [`Heading`](/docs/components/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](/docs/components/card)                               |
| `Callout`, `CalloutContainer`, `CalloutTitle`, `CalloutDescription`          | [Callouts](/docs/components/callout)                         |

The `docs` block's `components/mdx.tsx` also adds [Tabs](/docs/components/tabs), [Steps](/docs/components/steps), [Accordion](/docs/components/accordion), [Files](/docs/components/files) and [TypeTable](/docs/components/type-table), 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 [#relative-links]

`createRelativeLink` resolves links to other MDX files (`[Next](./next.mdx)`) to their page URLs. It works in server components only:

```tsx
<MDX components={getMDXComponents({ a: createRelativeLink(source, page) })} />
```