collab/mermaid/docs/config/icons.mdblame
View source
6dd74de1> **Warning**
6dd74de2>
6dd74de3> ## THIS IS AN AUTOGENERATED FILE. DO NOT EDIT.
6dd74de4>
6dd74de5> ## Please edit the corresponding file in [/packages/mermaid/src/docs/config/icons.md](../../packages/mermaid/src/docs/config/icons.md).
6dd74de6
6dd74de7# Registering icon pack in mermaid
6dd74de8
6dd74de9The icon packs available can be found at [icones.js.org](https://icones.js.org/).
6dd74de10We use the name defined when registering the icon pack, to override the prefix field of the iconify pack. This allows the user to use shorter names for the icons. It also allows us to load a particular pack only when it is used in a diagram.
6dd74de11
6dd74de12Using JSON file directly from CDN:
6dd74de13
6dd74de14```js
6dd74de15import mermaid from 'CDN/mermaid.esm.mjs';
6dd74de16mermaid.registerIconPacks([
6dd74de17 {
6dd74de18 name: 'logos',
6dd74de19 loader: () =>
6dd74de20 fetch('https://unpkg.com/@iconify-json/logos@1/icons.json').then((res) => res.json()),
6dd74de21 },
6dd74de22]);
6dd74de23```
6dd74de24
6dd74de25Using packages and a bundler:
6dd74de26
6dd74de27```bash
6dd74de28npm install @iconify-json/logos@1
6dd74de29```
6dd74de30
6dd74de31With lazy loading
6dd74de32
6dd74de33```js
6dd74de34import mermaid from 'mermaid';
6dd74de35
6dd74de36mermaid.registerIconPacks([
6dd74de37 {
6dd74de38 name: 'logos',
6dd74de39 loader: () => import('@iconify-json/logos').then((module) => module.icons),
6dd74de40 },
6dd74de41]);
6dd74de42```
6dd74de43
6dd74de44Without lazy loading
6dd74de45
6dd74de46```js
6dd74de47import mermaid from 'mermaid';
6dd74de48import { icons } from '@iconify-json/logos';
6dd74de49mermaid.registerIconPacks([
6dd74de50 {
6dd74de51 name: icons.prefix, // To use the prefix defined in the icon pack
6dd74de52 icons,
6dd74de53 },
6dd74de54]);
6dd74de55```