---
title: "Code groups"
description: "Show the same code in several languages or package managers, as tabs or a dropdown."
---

A `CodeGroup` turns the code blocks inside it into tabs. A block's tab is named by its title, or its language when it
has none. For block titles and other options, see [formatting](/write/formatting).

```bash npm
npm install specly
```

```bash pnpm
pnpm add specly
```

```bash yarn
yarn add specly
```

````mdx
<CodeGroup>

```bash npm
npm install specly
```

```bash pnpm
pnpm add specly
```

```bash yarn
yarn add specly
```

</CodeGroup>
````

Leave a blank line between the tag and the code blocks.

When a reader picks a tab, every group on the site that has that language (or that package manager) switches with
it, and Specly remembers the choice for their next visit.

## As a dropdown

```js Node
console.log('hello');
```

```python Python
print('hello')
```

````mdx
<CodeGroup dropdown>

```js Node
console.log('hello');
```

```python Python
print('hello')
```

</CodeGroup>
````

## Props

- `dropdown` (boolean, default: `false`): Shows a select box in place of the tabs.

- `sync` (boolean, default: `true`): Set `sync={false}` to keep a group to itself, so it neither follows nor changes the reader's choice.
