Content

Code

Fenced code blocks are highlighted with Shiki at compile time. A title adds a file name header, and :::code-group turns several blocks into accessible tabs.

Live demo

Click the deck, then use ← → · 2 slides · 00:02Open fullscreen →

Syntax

MarkdownMarkdown
```ts title="recit.config.ts" export default defineConfig({}) ``` :::code-group ```bash title="pnpm" pnpm add -D @recit/cli ``` ```bash title="npm" npm install -D @recit/cli ``` :::
MDXMDX
<CodeBlock language="ts" fileName="recit.config.ts" code={`export default defineConfig({})`} /> <CodeGroup tabs={[ { label: "pnpm", language: "bash", code: "pnpm add -D @recit/cli" }, { label: "npm", language: "bash", code: "npm install -D @recit/cli" }, ]} />
  • title="…" (or [label]) adds a file name header and names the tab in a code group.
  • Markdown code blocks are highlighted at build time with syntaxHighlighting.themes of recit.config.ts, in both modes. <CodeBlock> highlights on the client with a single theme, the dark one of that pair by default.
  • In MDX, <CodeBlock> and <CodeGroup> highlight code on the client.

Attributes and props

CodeBlock

PropTypeDefaultDescription
codestring—Source code (required)
languagestring—Shiki language (required)
fileNamestring—Header above the code
themestringgithub-darkShiki theme
showLineNumbersbooleantrueLine numbers in the gutter
autoFitbooleantrueSmaller font for long snippets

CodeGroup

PropTypeDefaultDescription
tabs{ label, language, code }[]—One tab per snippet

In other formats

FormatStatusNotes
deckAvailableRendered in slides, the presenter console and the HTML and PDF exports.
docsAvailableThrough <StoryEmbed slug="…" /> in any page of a site.
motionAvailableAnimated block in a film.
reportPlanned · P6Section of a paged report.
toonPlanned · P7Panel of a vertical strip.
bookPlanned · P8Block of a printable chapter.
Last modified on