> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify-mintlify-add-hello-world-quickstart-48843.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# 代码分组

> 在一个组件中展示多个代码示例

使用 `CodeGroup` 组件在带有选项卡的界面中展示多个代码块，便于用户对比不同编程语言的实现，或查看完成同一任务的不同方案。

<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>

代码分组会继承你在 `文档配置文件` 中设置的全局样式。可通过 `styling.codeblocks` 自定义主题。参见 [设置](/zh/settings#styling) 了解配置选项。

<div id="creating-code-groups">
  ## 创建代码组
</div>

要创建代码组，请用 `<CodeGroup>` 标签包裹多个代码块。每个代码块必须包含一个标题，标题将作为选项卡的标签显示。

````mdx
<CodeGroup>

```javascript helloWorld.js
console.log("你好世界");
```

```python hello_world.py
print('你好世界!')
```

```java HelloWorld.java
class HelloWorld {
    public static void main(String[] args) {
        System.out.println("你好，世界！");
    }
}
```

</CodeGroup>
````

<div id="language-dropdown">
  ## 语言下拉菜单
</div>

你可以使用 `dropdown` 属性将代码组中的选项卡替换为下拉菜单，以在不同语言之间切换。

<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("你好世界");
```

```python hello_world.py
print('你好世界!')
```

```java HelloWorld.java
class HelloWorld {
    public static void main(String[] args) {
        System.out.println("你好，世界！");
    }
}
```
</CodeGroup>
````
