CodeBlock Component

Display multiple related code snippets with headings using the <CodeBlock> component, ideal for showing request/response examples or comparing different code files.

Syntax

<CodeBlock slots="heading, code" repeat="2" languages="JSON, JSON" />

#### Request

```json
{
  "name": "example"
}
```

#### Response

```json
{
  "status": "success"
}
```

Ex:

data-slots=heading, code
data-repeat=2
data-languages=JSON, JSON

Request

{
  "name": "example"
}

Response

{
  "status": "success"
}

Parameters

Supported Languages

The following language identifiers are supported:

bash, c, cpp, csharp, css, git, go, graphql, http, java, javadoc, javascript, jsdoc, json, json5, jsx, less, markdown, markup, objectc, php, python, regex, rest, sass, sql, typescript, xml-doc, yaml

Variants

When to Use

Use the CodeBlock component when you need to:

For single code snippets, use regular markdown code blocks instead.