Code group
Code groups let you display multiple code blocks as tabs, with optional language switching. This is useful for showing the same code in different languages, or grouping related code snippets together.
Basic usage
Wrap multiple code blocks in a <CodeGroup> component. Each code block's title becomes a tab. Example:
Source:
Language variants
When multiple code blocks share the same title but have different languages, they are grouped into a single tab with a language selector. Switching languages updates all tabs to show the selected language variant (if available). Example:
Source:
Synced tabs with groupId
By default, all code groups share the selected language globally. To also sync the selected tab across multiple code groups, use the groupId prop. Code groups with the same groupId will keep their active tab in sync. Try clicking a tab below — the other code group will update:
Source: