Skip to content

feat: register Iconify icon packs so diagram icons render - #2017

Open
dariodd wants to merge 1 commit into
mermaid-js:developfrom
dariodd:register-icon-packs
Open

feat: register Iconify icon packs so diagram icons render#2017
dariodd wants to merge 1 commit into
mermaid-js:developfrom
dariodd:register-icon-packs

Conversation

@dariodd

@dariodd dariodd commented Aug 6, 2026

Copy link
Copy Markdown

The problem

mermaid ships no icons beyond architecture-beta's five built-ins (cloud, database, disk, internet, server). Every other icon — logos:aws, mdi:database, an icon: on a flowchart node — is resolved against packs the host registers, and the Live Editor registers none.

So today, in the Live Editor:

architecture-beta
  service a(logos:aws)[AWS]
  service b(server)[Server]

b renders. a renders as mermaid's blue "?" placeholder — as does every icon in the icon documentation's own examples, and every icon in a diagram brought here from a tool that does register packs.

The change

Register eight common Iconify packs with CDN loaders, exactly as the documentation describes:

mermaid.registerIconPacks(
  ICON_PACKS.map((name) => ({
    name,
    loader: () =>
      fetch(`https://unpkg.com/@iconify-json/${name}@1/icons.json`).then((res) => res.json())
  }))
);

logos, simple-icons, mdi, fa6-solid, fa6-brands, carbon, tabler, devicon.

Cost

Nothing until an icon is used. mermaid calls a loader only when a diagram names that pack, and caches the result — so a session that draws no icons makes no request, and one that uses logos: fetches logos alone. Nothing is added to the bundle and there is no new dependency.

If a fetch fails — offline, or a self-hosted instance with no outbound access — mermaid falls back to the same "?" placeholder shown today. Nothing regresses.

Alternatives considered

  • Bundling the packs (@iconify-json/* as dependencies with import() loaders) keeps it offline, but mdi alone is 3.1 MB and the eight together are far more; a CDN fetch on demand seemed the better trade for a hosted editor. Happy to switch if you would rather not depend on unpkg.
  • A different pack list. These eight are a guess at what people reach for; glad to trim or extend it.

Tests

Not included on purpose: the only meaningful assertion is "an icon rendered", which needs a real network fetch and would make CI flaky. Happy to add a Playwright test behind a mock if you would like one.

mermaid ships no icons beyond architecture-beta's five built-ins. Everything
else — `logos:aws`, `mdi:database`, an `icon:` on a flowchart node — resolves
against packs the host registers, and the Live Editor registers none, so every
such icon renders as mermaid's "?" placeholder. That includes the examples in
the icon documentation itself.

Register eight common packs with CDN loaders, as
https://mermaid.js.org/config/icons.html describes. mermaid calls a loader
only when a diagram names that pack, so nothing is downloaded until an icon is
actually used, and a failed fetch falls back to today's placeholder.
@netlify

netlify Bot commented Aug 6, 2026

Copy link
Copy Markdown

Deploy Preview for mermaidjs ready!

Name Link
🔨 Latest commit bf6d114
🔍 Latest deploy log https://app.netlify.com/projects/mermaidjs/deploys/6a74f168af3f16000882d01e
😎 Deploy Preview https://deploy-preview-2017--mermaidjs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant