Skip to main content
SolidBase

Preview Directive

since v0.6.0Source

The preview directive renders MDX content inside the default theme preview shell.

Syntax

:::preview
<RenderedExample />
---
```tsx tab title="index.tsx"
export function RenderedExample() {
return <button>Save</button>;
}
```
:::

Structure

PartRequiredDescription
:::previewYesStarts the preview directive. Titles are not supported.
Content before ---YesRendered into the PreviewStage slot.
First top-level ---NoSplits the preview stage from the supporting panel.
Content after ---Yes, when --- existsRendered into the PreviewPanel slot.
Closing fenceYesEnds the directive. Use a longer fence when nesting other directives.

Rendered Components

A preview directive renders through these MDX components:

ComponentPurpose
PreviewWraps the whole preview block.
PreviewStageWraps rendered content above the divider.
PreviewPanelWraps supporting content below the divider.

Custom themes should provide all three components when overriding the MDX component map.

Validation

The parser rejects:

Invalid inputReason
Empty :::previewThe stage is required.
:::preview with only ---The stage and panel are both empty.
:::preview with empty content before ---The stage is required.
:::preview with empty content after ---A divider requires panel content.
:::preview TitlePreview directive titles are not supported.

Divider Behavior

Only the first top-level thematic break splits the preview.

Additional thematic breaks after the first divider stay inside PreviewPanel.

Nested Directives

When a preview contains another container directive, use a longer outer fence.

::::preview
<RenderedExample />
---
:::tip
Use a longer outer fence when the panel contains another directive.
:::
::::

Preview-Only Example

:::preview
<RenderedExample />
:::

Preview With Panel Example

:::preview
<RenderedExample />
---
```tsx tab title="index.tsx"
export function RenderedExample() {
return <button>Save</button>;
}
```
:::

Last updated: 4/23/26, 10:57 PM

SolidBaseFully featured, fully customisable static site generation for SolidStart
Community
githubdiscord