Code blocks
Fenced code blocks are highlighted during the build. Each rendered block includes a copy button, so keep executable commands separate from explanatory output.
Label a code block
Add a language after the opening fence. Use title="filename" to label the block:
```sh title="Install"
pnpm add my-project
```
The result is:
pnpm add my-project
The title is a display label; it does not create a file. For a config example,
use a filename such as docskit.config.ts so the reader knows where to paste it.
Show alternatives in tabs
Use an .md page for CodeTabs and CodeTab. They are included in the default
Markdown component map, so a page does not need to import them.
<CodeTabs>
<CodeTab label="pnpm">
```sh
pnpm add my-project
```
</CodeTab>
<CodeTab label="npm">
```sh
npm install my-project
```
</CodeTab>
</CodeTabs>
The result is:
pnpm add my-project
npm install my-project
Put blank lines around each fence. Every tab needs a unique, nonempty string
label. CodeTabs must contain CodeTab elements and at least one tab. Invalid
structure fails the build with the source location.
The build derives tab metadata from these elements. Write the labels and code
in the page; the tabs metadata prop is generated internally.
Check the published example
Run pnpm build after adding tabs, then use pnpm preview to check the rendered
page and copy buttons. For custom elements beyond the built-in Markdown map, see
Components and styles.