Skip to contentSkip to Content
ComponentsPreviewCode

PreviewCode

Pair a rendered component example with the exact MDX source that produced it. Use PreviewCode for component catalog examples so readers can inspect the result first and switch to the code without scrolling through a duplicated section.

API

PreviewCode

PropTypeDefaultDescription
titlestringOptional heading shown above the preview/code switcher.
descriptionstringOptional short context for the example.
defaultMode"preview" | "code""preview"Initial tab.
childrenReactNodeInclude one fenced code block plus the rendered preview content.

Example

Callout example

The first fenced block becomes the Code tab. The remaining children become the Preview tab.

Use real output

Prefer generated pages, command output, and source snippets over abstract placeholders.

<Callout type="tip" title="Use real output"> Prefer generated pages, command output, and source snippets over abstract placeholders. </Callout>