Skip to content

Commit 1954cb3

Browse files
committed
bring changes from #878
1 parent 70faed5 commit 1954cb3

File tree

1 file changed

+13
-17
lines changed

1 file changed

+13
-17
lines changed

components/code-groups.mdx

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
---
22
title: "Code groups"
3-
description: "The CodeGroup component lets you combine code blocks in a display separated by tabs"
3+
description: "Display multiple code examples in one component"
44
icon: "group"
55
---
66

7-
You will need to make [Code Blocks](/code) then add the `<CodeGroup>` component around them. Every Code Block must have a filename because we use the names for the tab buttons.
8-
9-
See below for an example of the end result.
7+
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.
108

119
<CodeGroup>
1210

@@ -28,11 +26,12 @@ class HelloWorld {
2826

2927
</CodeGroup>
3028

31-
## Language dropdown
29+
## Creating code groups
3230

33-
You can replace the tabs in a code group with a dropdown menu to toggle between languages using the `dropdown` prop.
31+
To create a code group, wrap multiple code blocks with `<CodeGroup>` tags. Each code block must include a title, which becomes the tab label.
3432

35-
<CodeGroup dropdown>
33+
````mdx
34+
<CodeGroup>
3635

3736
```javascript helloWorld.js
3837
console.log("Hello World");
@@ -51,9 +50,12 @@ class HelloWorld {
5150
```
5251

5352
</CodeGroup>
53+
````
5454

55+
## Language dropdown
56+
57+
You can replace the tabs in a code group with a dropdown menu to toggle between languages using the `dropdown` prop.
5558

56-
````mdx highlight=1
5759
<CodeGroup dropdown>
5860

5961
```javascript helloWorld.js
@@ -71,14 +73,11 @@ class HelloWorld {
7173
}
7274
}
7375
```
74-
</CodeGroup>
75-
````
76-
7776

78-
<RequestExample>
77+
</CodeGroup>
7978

80-
````mdx Code Group Example
81-
<CodeGroup>
79+
````mdx highlight=1
80+
<CodeGroup dropdown>
8281

8382
```javascript helloWorld.js
8483
console.log("Hello World");
@@ -95,8 +94,5 @@ class HelloWorld {
9594
}
9695
}
9796
```
98-
9997
</CodeGroup>
10098
````
101-
102-
</RequestExample>

0 commit comments

Comments
 (0)