| 1 | --- |
| 2 | name: code-groups |
| 3 | description: Group multiple code blocks with tabs and automatic icons |
| 4 | --- |
| 5 | |
| 6 | # Code Groups |
| 7 | |
| 8 | Group multiple code blocks with tabs and automatic icons. |
| 9 | |
| 10 | ## Requirements |
| 11 | |
| 12 | Enable Comark syntax in headmatter: |
| 13 | |
| 14 | ```md |
| 15 | --- |
| 16 | comark: true |
| 17 | --- |
| 18 | ``` |
| 19 | |
| 20 | ## Syntax |
| 21 | |
| 22 | ````md |
| 23 | ::code-group |
| 24 | |
| 25 | ```sh [npm] |
| 26 | npm i @slidev/cli |
| 27 | ``` |
| 28 | |
| 29 | ```sh [yarn] |
| 30 | yarn add @slidev/cli |
| 31 | ``` |
| 32 | |
| 33 | ```sh [pnpm] |
| 34 | pnpm add @slidev/cli |
| 35 | ``` |
| 36 | |
| 37 | :: |
| 38 | ```` |
| 39 | |
| 40 | ## Title Icon Matching |
| 41 | |
| 42 | Icons auto-match by title name. Install `@iconify-json/vscode-icons` for built-in icons. |
| 43 | |
| 44 | Supported: npm, yarn, pnpm, bun, deno, vue, react, typescript, javascript, and many more. |
| 45 | |
| 46 | ## Custom Icons |
| 47 | |
| 48 | Use `~icon~` syntax in title: |
| 49 | |
| 50 | ````md |
| 51 | ```js [npm ~i-uil:github~] |
| 52 | console.log('Hello!') |
| 53 | ``` |
| 54 | ```` |
| 55 | |
| 56 | Requires: |
| 57 | 1. Install icon collection: `pnpm add @iconify-json/uil` |
| 58 | 2. Add to safelist in `uno.config.ts`: |
| 59 | |
| 60 | ```ts |
| 61 | export default defineConfig({ |
| 62 | safelist: ['i-uil:github'] |
| 63 | }) |
| 64 | ``` |
| 65 |