You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: fern/products/docs/pages/component-library/default-components/code-blocks.mdx
+13-2Lines changed: 13 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -306,9 +306,16 @@ The `CodeBlocks` component allows you to display multiple code blocks in a tabbe
306
306
</Tab>
307
307
</Tabs>
308
308
309
-
## Example of Synchronized Blocks
309
+
## Language synchronization
310
310
311
-
Multiple `CodeBlocks` on a page automatically synchronize, showing the same language across all blocks.
311
+
Multiple `CodeBlocks` on a documentation site automatically synchronize. This
312
+
means when a user selects a `CodeBlock` with a specific language, all other
313
+
`CodeBlocks` across your documentation site with the same language will
314
+
automatically sync and switch to match. Language preferences are stored in
315
+
client-side local storage and persist across browser sessions.
316
+
317
+
The example below demonstrates language sync in action – choosing a language in
318
+
either set of code blocks will automatically update both sets to match:
312
319
313
320
<CodeBlocks>
314
321
```python title="Python"
@@ -362,6 +369,10 @@ Multiple `CodeBlocks` on a page automatically synchronize, showing the same lang
362
369
```
363
370
</CodeBlocks>
364
371
372
+
<Notetitle="Tabs and CodeBlocks integration">
373
+
`CodeBlocks` automatically synchronize with [`<Tab>` components that have a `language` property](/docs/writing-content/components/tabs#language-synchronization).
374
+
</Note>
375
+
365
376
### Override synchronization
366
377
367
378
You can override the synchronization of code blocks by setting the `for` prop.
description: 'The Tabs component allows you to display related content in a tabbed view.'
2
+
title: Tabs
3
+
description: The Tabs component allows you to display related content in a tabbed view with support for language synchronization.
4
4
---
5
5
6
-
The Tabs component organizes content into separate tabs that users can switch between. Each tab can contain different types of content like examples or code snippets.
The content to be displayed when the tab is selected. Can include text, markdown, and components.
21
-
</ParamField>
22
-
23
-
<br />
6
+
The Tabs component organizes content into separate tabs that users can switch between. Each tab can contain different types of content like examples, code snippets, or documentation sections.
24
7
25
8
<Tabs>
26
9
<Tabtitle="First Tab">
@@ -34,8 +17,6 @@ The Tabs component organizes content into separate tabs that users can switch be
34
17
</Tab>
35
18
</Tabs>
36
19
37
-
<Aside>
38
-
39
20
<CodeBlocktitle="Markdown">
40
21
```jsx
41
22
<Tabs>
@@ -52,4 +33,69 @@ The Tabs component organizes content into separate tabs that users can switch be
The content to be displayed when the tab is selected. Can include text, markdown, and components.
50
+
</ParamField>
51
+
52
+
## Language synchronization
53
+
54
+
Multiple `Tabs` with a `language` property automatically synchronize. This means
55
+
when a user selects a tab with a specific language, all other tabs across your
56
+
documentation site with the same language will automatically sync and switch to
57
+
match. Language preferences are stored in client-side local storage and persist
58
+
across browser sessions.
59
+
60
+
The example below demonstrates language sync in action – choosing a language in
61
+
either set of tabs will automatically update both sets to match:
62
+
63
+
<Tabs>
64
+
<Tabtitle="TypeScript"language="typescript">
65
+
```typescript
66
+
console.log("First code block!");
67
+
```
68
+
</Tab>
69
+
<Tabtitle="Python"language="python">
70
+
```python
71
+
print("First code block!")
72
+
```
73
+
</Tab>
74
+
<Tabtitle="Java"language="java">
75
+
```java
76
+
System.out.println("First code block!");
77
+
```
78
+
</Tab>
79
+
</Tabs>
80
+
81
+
<Tabs>
82
+
<Tabtitle="TypeScript"language="typescript">
83
+
```typescript
84
+
console.log("Second code block – language syncs with the one above!");
85
+
```
86
+
</Tab>
87
+
<Tabtitle="Python"language="python">
88
+
```python
89
+
print("Second code block – language syncs with the one above!")
90
+
```
91
+
</Tab>
92
+
<Tabtitle="Java"language="java">
93
+
```java
94
+
System.out.println("Second code block – language syncs with the one above!");
95
+
```
96
+
</Tab>
97
+
</Tabs>
98
+
99
+
<Notetitle="Tabs and CodeBlocks integration">
100
+
Language-enabled `Tabs` automatically synchronize with [`CodeBlocks` in that same language](/docs/writing-content/components/code-blocks#language-synchronization).
0 commit comments