Skip to content

ButterIX v1 is out: versions, multiple languages, Ask AI, and a per-site MCP server, all built in. →

Code block

<CodeBlock> controls a code block's title, highlighting, focus, line numbers and collapsing with props.

Most of the time a plain fenced code block is all you need; for meta syntax (titles, line highlighting, focus, max lines…) see Code blocks.

Uses props instead of fence meta — handy when there are many options or you need links:

<CodeBlock title="client.ts" highlight="2" maxLines={0} links={{ "createClient": "/api-reference", "/get\\w+/": "/api-reference" }}>
```ts
import { createClient } from "@acme/sdk";
const client = createClient({ apiKey: process.env.ACME_KEY });
const me = await client.getMe();
```
</CodeBlock>
client.ts
import { createClient } from "@acme/sdk";
const client = createClient({ apiKey: process.env.ACME_KEY });
const me = await client.getMe();
titlestring
Title (filename also works).
languagestring
Language (lang also works); defaults to the fence's language.
highlightstring
Lines to highlight, e.g. "2-4, 6".
focusstring
Lines to focus; the rest are dimmed.
startLinenumber
Starting line number.
maxLinesnumberDefault 20
Maximum visible lines; 0 means no limit.
wordWrapboolean
Wrap long lines.
showLineNumbersboolean
Show / hide line numbers (lineNumbers also works).
forstring
Custom sync group.
collapsibleboolean
When the block exceeds the max lines, collapse it behind "Show more" instead of scrolling.