Files
mintlify__docs/components/code-groups.mdx
mintlify[bot] bad67622c0 Updated codeblock styling documentation with new theme options (#1252)
* Update settings.mdx

* Update code.mdx

* Update components/code-groups.mdx

* Update settings.mdx

* Update code.mdx

* Update components/code-groups.mdx

* Update settings.mdx

* Update code.mdx

* Update components/code-groups.mdx

* copy edits

---------

Co-authored-by: mintlify[bot] <109931778+mintlify[bot]@users.noreply.github.com>
Co-authored-by: Ethan Palm <56270045+ethanpalm@users.noreply.github.com>
2025-09-23 19:30:13 -07:00

101 lines
2.0 KiB
Plaintext

---
title: "Code groups"
description: "Display multiple code examples in one component"
icon: "group"
---
Use the `CodeGroup` component to display multiple code blocks in a tabbed interface, allowing users to compare implementations across different programming languages or see alternative approaches for the same task.
<CodeGroup>
```javascript helloWorld.js
console.log("Hello World");
```
```python hello_world.py
print('Hello World!')
```
```java HelloWorld.java
class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}
```
</CodeGroup>
Code groups inherit global styling from your `docs.json` file. Customize your theme using `styling.codeblocks`. See [Settings](/settings#styling) for configuration options.
## Creating code groups
To create a code group, wrap multiple code blocks with `<CodeGroup>` tags. Each code block must include a title, which becomes the tab label.
````mdx
<CodeGroup>
```javascript helloWorld.js
console.log("Hello World");
```
```python hello_world.py
print('Hello World!')
```
```java HelloWorld.java
class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}
```
</CodeGroup>
````
## Language dropdown
You can replace the tabs in a code group with a dropdown menu to toggle between languages using the `dropdown` prop.
<CodeGroup dropdown>
```javascript helloWorld.js
console.log("Hello World");
```
```python hello_world.py
print('Hello World!')
```
```java HelloWorld.java
class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}
```
</CodeGroup>
````mdx highlight=1
<CodeGroup dropdown>
```javascript helloWorld.js
console.log("Hello World");
```
```python hello_world.py
print('Hello World!')
```
```java HelloWorld.java
class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}
```
</CodeGroup>
````