Skip to content

MDX components

Doctrine registers its built-ins in every MDX page. Importing is unnecessary inside MDX; component values and prop types are also public from @amamo/doctrine/components for custom modules.

Built-in components

The sections below document each public component next to its example. An “other attributes” row means the component also accepts the listed native React attributes, including className, id, aria-*, and data-*.

Native writing elements

Doctrine also typesets semantic HTML directly, so common writing patterns do not need a React component. Markdown blockquotes and tables work as usual; MDX can use <details> and <summary> for disclosure, <kbd> for keyboard input, <mark> for highlights, <dl> for definitions, and <figure> with <figcaption> for captioned media. They share the theme, narrow-screen behavior, focus treatment, and print styles.

MDX
<details>  <summary>Why is the output static?</summary>Every route is prerendered during the build.</details>Press <kbd>Ctrl</kbd> + <kbd>K</kbd> to search.
Why is the output static?

Every route is prerendered during the build.

Press Ctrl + K to search.

Headings and table of contents

@amamo/mdx assigns heading IDs and exports the table of contents while compiling each page. Doctrine renders that metadata into the initial HTML, including inline formatting in headings. Duplicate headings receive -1, -2, and later suffixes. Append [#custom-id] to choose an explicit anchor without rendering the suffix:

MDX
## Runtime lifecycle [#runtime]

Code blocks

Fenced code blocks use One Light and Andromeeda for light and dark mode. They show the detected language with its icon when available and include a copy action automatically. Add filename="..." to the fence metadata when a filename should appear:

MDX
```ts filename="doctrine.config.ts"export default {  title: 'Documentation',}```
TypeScriptdoctrine.config.ts
export default {  title: 'Documentation',}

Code metadata and inline annotations are handled during compilation. Use {2,4-5} to highlight lines, /createApp/ to highlight matching words, or // [!code ...] with highlight, focus, ++, --, error, warning, info, or word:value. Annotation comments are omitted from the rendered and copied code.

MDX
```ts filename="app.ts" {1} /createApp/const app = createApp()app.mount('#root')app.start() // [!code ++]```
TypeScriptapp.ts
const app = createApp()app.mount('#root')app.start()

Callout

Use a callout to separate contextual notes, recommendations, warnings, and blocking problems from the surrounding content.

PropTypeRequiredDefaultDescription
childrenReactNodeNo—Callout body
titlestringNo—Heading above the body
variant"note" | "tip" | "warning" | "danger"No"note"Color and icon treatment
Other attributesHTMLAttributes<HTMLElement>No—Forwarded to the root <aside>
MDX
<Callout variant="tip" title="Ready to deploy">  Run the production build before uploading `dist`.</Callout>

Badge

Use a badge for a short status or label inside a sentence or heading.

PropTypeRequiredDefaultDescription
childrenReactNodeNo—Badge content
variant"default" | "outline"No"default"Filled or outlined appearance
Other attributesHTMLAttributes<HTMLSpanElement>No—Forwarded to the root <span>
MDX
<Badge>Stable</Badge> <Badge variant="outline">Preview</Badge>
Stable Preview

Card and CardGrid

Card

Card is a presentation container, not a link. Put a Markdown link inside when the card should lead somewhere.

PropTypeRequiredDefaultDescription
childrenReactNodeNo—Card body
titlestringNo—Heading above the body
Other attributesHTMLAttributes<HTMLDivElement>No—Forwarded to the root <div>
MDX
<Card title="Installation">Start with [Getting started](/getting-started/).</Card>

Installation

Start with Getting started.

CardGrid

Use CardGrid to arrange cards in one column on narrow screens and two columns when space permits.

PropTypeRequiredDefaultDescription
childrenReactNodeNo—Cards or other grid items
Other attributesHTMLAttributes<HTMLDivElement>No—Forwarded to the root <div>
MDX
<CardGrid>  <Card title="Installation">Start with [Getting started](/getting-started/).</Card>  <Card title="Deployment">Copy the [GitHub Pages workflow](/deployment/).</Card></CardGrid>

Installation

Start with Getting started.

Deployment

Steps and Step

Steps

Steps renders an ordered sequence and numbers each direct Step child.

PropTypeRequiredDefaultDescription
childrenReactNodeNo—Sequence of Step elements
Other attributesHTMLAttributes<HTMLOListElement>No—Forwarded to the root <ol>
MDX
<Steps>  <Step title="Write">Create an MDX file.</Step>  <Step title="Preview">Run the development server.</Step>  <Step title="Build">Generate static files.</Step></Steps>
  1. Write

    Create an MDX file.
  2. Preview

    Run the development server.
  3. Build

    Generate static files.

Step

Use Step only inside Steps. The parent list supplies its visible number.

PropTypeRequiredDefaultDescription
childrenReactNodeNo—Step body
titlestringNo—Heading above the step body
Other attributesHTMLAttributes<HTMLLIElement>No—Forwarded to the root <li>

LivePreview

LivePreview renders normal MDX children, so React event handlers hydrate with the page. Pass source to add an optional native source disclosure; Doctrine does not ship a browser compiler or editor.

PropTypeRequiredDefaultDescription
childrenReactNodeYes—Rendered preview
languagestringNo"tsx"Language label for the optional source block
sourcestringNo—Source shown in a collapsible block
titleReactNodeNo—Header above the preview
Other attributesOmit<HTMLAttributes<HTMLElement>, "title">No—Forwarded to the root <section>
MDX
<LivePreview source={`<PreviewCounter />`} title="Interactive counter">  <PreviewCounter /></LivePreview>
Interactive counter
Sourcetsx
TSX
<PreviewCounter />

FileTree

FileTree provides the root container for a static semantic file list.

PropTypeRequiredDefaultDescription
childrenReactNodeYes—Folder and file entries
Other attributesHTMLAttributes<HTMLDivElement>No—Forwarded to the root <div>
MDX
<FileTree>  <FileTreeFolder name="docs">    <FileTreeFile active name="index.mdx" />    <FileTreeFile name="getting-started.mdx" />  </FileTreeFolder>  <FileTreeFile name="doctrine.config.ts" />  <FileTreeFile name="package.json" /></FileTree>
  • docs
    • index.mdx
    • getting-started.mdx
  • doctrine.config.ts
  • package.json

FileTreeFolder

Use FileTreeFolder inside FileTree to group nested folders and files.

PropTypeRequiredDefaultDescription
childrenReactNodeYes—Nested folder and file entries
nameReactNodeYes—Visible folder name
Other attributesHTMLAttributes<HTMLLIElement>No—Forwarded to the root <li>

FileTreeFile

Use FileTreeFile inside FileTree or FileTreeFolder. Set active only on the file represented by the current example.

PropTypeRequiredDefaultDescription
activebooleanNofalseMarks the current file
nameReactNodeYes—Visible file name
Other attributesHTMLAttributes<HTMLLIElement>No—Forwarded to the root <li>

InstallTabs

InstallTabs renders the pnpm, npm, Yarn, and Bun install commands for one package.

PropTypeRequiredDefaultDescription
devbooleanNofalseAdds each manager's dev flag
packageNamestringYes—Package passed to every command
MDX
<InstallTabs packageName="@amamo/doctrine" />
Shell
pnpm add @amamo/doctrine

Tabs and Tab

Tabs

Use Tabs to group related panels. It selects the first Tab when defaultValue is omitted.

PropTypeRequiredDefaultDescription
childrenReactNodeYes—Sequence of Tab elements
classNamestringNo—Class on the root element
defaultValuestringNoFirst tab valueInitially selected tab
variant"default" | "line"No"default"Tab-list appearance
MDX
<Tabs defaultValue="preview" variant="line">  <Tab label="Preview" value="preview">    Rendered output  </Tab>  <Tab label="Source" value="source">    MDX source  </Tab></Tabs>

Rendered output

Tab

Use Tab only inside Tabs; it declares one tab control and its matching panel.

PropTypeRequiredDefaultDescription
childrenReactNodeYes—Panel content
labelReactNodeYes—Tab control content
valuestringNoZero-based indexStable tab and panel key

To add project-specific names or override a built-in, continue with Customization.

copyright © 2026 白熱。