Markdown in, stunning docs out. No JavaScript toolchain, no config. ⭐ Star us on GitHub

Code Groups

Code Groups let you show multiple related code files together, perfect for showing different files in a project or different versions of the same code.

Basic Code Group

dart
void main() {
runApp(MyApp());
}
markdown
<CodeGroup>
  <Code title="main.dart" language="dart">
void main() {
  runApp(MyApp());
}
  </Code>
  <Code title="pubspec.yaml" language="yaml">
name: my_app
dependencies:
  flutter:
    sdk: flutter
  </Code>
</CodeGroup>

Synced Code Groups

Like Tabs, a CodeGroup accepts a group attribute. Groups sharing a name switch together and remember the choice across pages, matched by the Code block's title:

markdown
<CodeGroup group="pkg-manager">
  <Code title="npm">npm install my-package</Code>
  <Code title="pnpm">pnpm add my-package</Code>
</CodeGroup>

Project Structure Example

Show how files work together:

dart
import 'package:flutter/material.dart';
import 'app.dart';

void main() {
runApp(const MyApp());
}

Configuration Files

yaml
name: My Docs
description: Documentation for My Project

nav:
- label: Docs
  href: /

sidebar:
- group: Getting Started
  pages:
    - index
    - installation

API Request/Response

bash
curl -X POST https://api.example.com/users \
-H "Content-Type: application/json" \
-d '{"name": "John", "email": "john@example.com"}'

Before/After Example

dart
// Old approach - manual state management
class Counter {
int _value = 0;

void increment() {
  _value++;
  notifyListeners();
}
}

Supported Languages

Code Groups support all the same languages as regular code blocks:

  • dart, javascript, typescript, python, go, rust
  • java, kotlin, swift, c, cpp, csharp
  • ruby, php, sql, graphql
  • yaml, json, toml, xml
  • bash, shell, powershell
  • html, css, scss
  • And many more...

Code Groups vs Tabs

Info

Use Code Groups when showing related files that work together.

Use Tabs when showing alternative implementations (different languages doing the same thing).

Code Groups - Multiple files in one project:

html
<div id="app"></div>

Tabs - Same thing in different languages:

javascript
console.log('Hello');
3 min readLast updated 2026-07-26Samuel Abada