Skip to main content

Code groups display multiple related code examples in tabs, perfect for showing the same functionality in different languages or approaches.

Basic Code Group

Create tabs by placing multiple code blocks together with title metadata:

The text after the language identifier becomes the tab title. Use descriptive names like "Example.js" or "Step 1".

Multi-Language API Examples

Show the same API call in different languages:

Installation Steps

Show installation for different package managers:

Configuration Options

Display different configuration approaches:

Step-by-Step Examples

Use tabs for sequential steps:

With Line Highlighting

Code groups support line highlighting:

Complex Examples

Show complete implementations across languages:

Best Practices

Use descriptive tab titles

Tab titles should clearly indicate what's inside. Use:

  • Language names: "JavaScript", "Python", "Rust"

  • File names: "config.json", "Example.ts"

  • Steps: "Step 1: Install", "Step 2: Configure"

Keep examples consistent

When showing the same operation in multiple languages, keep the logic and structure as similar as possible so users can easily compare.

Order tabs logically

Order tabs by:

  • Popularity (most common languages first)

  • Alphabetically

  • Sequentially (for steps)

Don't overuse tabs

Code groups are powerful but can be overwhelming. Use them when you genuinely need to show alternatives, not for every code block.

Combine with other features

Code groups work with:

  • Line highlighting

  • Syntax highlighting

  • Long code examples

  • Comments and documentation

Common Patterns

SDK Installation

Environment Setup

Framework Examples

Code groups are especially useful for documentation that serves multiple audiences (different languages, frameworks, or tools). They keep all options visible without cluttering the page.