- Documentation
- Components
- Code groups
Code groups
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.
npm install speclypnpm add speclyyarn add specly<CodeGroup>
```bash npmnpm install specly```
```bash pnpmpnpm add specly```
```bash yarnyarn 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
Section titled “As a dropdown”console.log('hello');print('hello')<CodeGroup dropdown>
```js Nodeconsole.log('hello');```
```python Pythonprint('hello')```
</CodeGroup>dropdownbooleanShows a select box in place of the tabs.
syncbooleanSet
sync={false}to keep a group to itself, so it neither follows nor changes the reader’s choice.