@explainer/mdx

The @explainer/mdx package provides MDX component overrides, custom components, and remark plugins used by the docs and blog apps.

Heading overrides

The package exports heading components (H1–H6) that automatically add anchor links to headings:

import { H1, H2, H3, H4, H5, H6 } from '@explainer/mdx'

Each heading renders with a clickable # anchor that links to the heading’s ID.

Other overrides

ExportPurpose
LinkEnhanced link component with external link handling
CodeInline code styling
ParagraphParagraph with proper spacing
UnorderedListStyled unordered list
OrderedListStyled ordered list

Components

The package includes custom MDX components accessible via directive syntax or JSX:

ComponentDirectiveDescription
Callout:::calloutAlert boxes with variants
CardGroup::::card-groupGrid card layouts
Card:::cardIndividual card in a group
Steps::::step-groupNumbered step container
Step:::stepIndividual step
CodeGroup:::codegroupTabbed code blocks
Preview::::::previewLive preview with source
PreviewDemo:::::code-previewPreview render panel
PreviewCode:::::content-previewPreview source panel
TabsJSX onlySwitchable tab panels
TabJSX onlyIndividual tab panel

Remark plugins

remarkAutoImport

Automatically adds import statements for MDX components used in a file. You do not need to manually import Callout, Steps, Tabs, etc. — they are injected automatically.

remarkDirectiveHandler

Transforms directive syntax (:::callout, ::::card-group, etc.) into JSX component calls. The mapping is defined in the componentMap:

remark-directive-handler.ts
const componentMap = {
  'card-group': 'CardGroup',
  'card': 'Card',
  'callout': 'Callout',
  'step-group': 'Steps',
  'step': 'Step',
  'preview': 'Preview',
  'code-preview': 'PreviewDemo',
  'content-preview': 'PreviewCode',
  'codegroup': 'CodeGroup',
  'code-group': 'CodeGroup',
}

Shiki configuration

The package exports the shared Shiki configuration used for code block syntax highlighting:

import { shikiConfig } from '@explainer/mdx/shiki'

See Syntax Highlighting for details on themes and transformers.