Skip to content

@streamdown/mermaid: plugin defaults override Mermaid's own theme and font #714

Closed

Description

@aryakapoor

createMermaidPlugin puts the caller's config on top of its own defaults:

const defaultConfig: MermaidConfig = {
  startOnLoad: false,
  theme: "default",
  securityLevel: "strict",
  fontFamily: "monospace",
  suppressErrorRendering: true,
};
// ...
let currentConfig = { ...defaultConfig, ...options.config };

Because of that, there's no way to get Mermaid's own theme and font back. On Mermaid 12, whose default theme is now redux-color, every diagram still draws with the old default theme in a monospace font.

Passing theme: undefined gets around the theme. Passing fontFamily: undefined doesn't help: Mermaid only writes its --mermaid-font-family rule when fontFamily is set, so the diagram ends up with no font rule at all.

We ended up writing our own small plugin so chat diagrams match the ones we draw elsewhere with Mermaid's defaults.

Could the plugin keep only the settings it needs (startOnLoad: false, and probably securityLevel and suppressErrorRendering) and leave theme and fontFamily to Mermaid unless the caller sets them? That changes how diagrams look for anyone relying on today's defaults, so it might need a major version or an opt-in option.

Seen on @streamdown/mermaid 1.0.3 (also current main) with mermaid 12.3.0. Happy to send a PR.

Activity

  1. DeepanB15 commented on Nov 8, 2026

    @DeepanB15
    Contributor

    Hi! I'd like to work on this issue. I'll fix the Mermaid theme and font configuration so native defaults are respected, and add tests to verify the changes.

    Could you assign this issue to me?

  2. sleitor commented on Nov 9, 2026

    @sleitor
    Contributor

    Feasibility check from a would-be contributor: I'm holding off on a PR here, since the reporter has already offered to send one and @DeepanB15 asked to be assigned yesterday. A competing PR wouldn't help.

    Some technical notes that may help whoever picks this up:

    • createMermaidPlugin spreads defaultConfig under options.config, so theme: 'default' and fontFamily: 'monospace' are always applied unless the caller overrides them. Per the report, theme: undefined restores Mermaid's theme but fontFamily: undefined leaves the diagram with no font rule.
    • Dropping theme and fontFamily from the defaults changes the look for existing users, so it probably needs a maintainer decision on semver (major) versus an opt-in. One opt-in shape would be a flag like useMermaidDefaults, or a way to pass null or undefined that actually removes the key. The current behaviour would stay the default.
    • Tests should cover three cases: no config, user-supplied theme/font, and the opt-out path. They should also check that startOnLoad, securityLevel and suppressErrorRendering stay enforced.
  3. DeepanB15 commented on Nov 9, 2026

    @DeepanB15
    Contributor

    Thanks for the detailed technical insights! I'll wait for the maintainer's guidance on the backward-compatible approach and assignment before proceeding. Appreciate the help!

  4. aryakapoor commented on Nov 9, 2026

    @aryakapoor
    Author

    Go ahead @DeepanB15, I won't send a competing PR. An opt-in like @sleitor describes works for us. We just need theme and fontFamily left to Mermaid, so its own defaults apply.

  5. DeepanB15 commented on Nov 10, 2026

    @DeepanB15
    Contributor

    Thanks for confirming! I'll proceed with the opt-in approach, maintain backward compatibility, and add the necessary tests before submitting a PR.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions