API reference#

Exports of @sigx/mermaid v0.1.0.

mermaid and sigx are peer dependencies; the package has no runtime dependencies of its own.

@sigx/mermaid#

ExportKindPurpose
MermaidcomponentThe diagram component. Props: code (required), title, options, eager, plus anything else forwarded to the <figure>.
MermaidPropstypeIts prop type.
configureMermaid(options)functionSet global options. Calls merge.
getMermaidConfig()functionRead the resolved global config.
resetMermaidConfig()functionClear it — useful between tests.
mergeMermaidConfig(a, b)functionThe merge used internally, exposed.
loadMermaid()functionLoad the mermaid module on demand.
renderDiagram(…)functionRender one diagram imperatively; returns a RenderResult.
resolveColorScheme()functionThe detected scheme ('light' | 'dark').
resolveTheme() / resolveSchemeTheme(scheme)functionThe resolved theme for the active or a given scheme.
defaultThemeVariables()functionThe variables the package supplies.
pageBackgroundColor()functionThe detected page background — the input to scheme detection's last step.
watchTheme(cb)functionSubscribe to appearance changes.
resetMermaidLoader()functionDrop the cached module, for tests.

Option types#

MermaidOptions, MermaidSchemeTheme, MermaidThemeName, MermaidThemes, MermaidThemeVariables, RenderResult.

MermaidOptions carries themes, securityLevel, config and resolveColorScheme — see Configuration.

@sigx/mermaid/client#

Installs on import.

ExportPurpose
installMermaid(options?)Install explicitly; returns a disposer. Safe to call repeatedly.
uninstallMermaid()Tear down whatever is installed. A no-op if nothing is.
MermaidClientOptions{ root?, rootMargin? }.

configureMermaid and getMermaidConfig are re-exported here, so a client-only entry needs one import.

@sigx/mermaid/ssg#

ExportPurpose
rehypeMermaid(options?)The rehype plugin. Also the default export.
RehypeMermaidOptions{ language?, className? }.
mermaidThemeContributionDrop-in ThemeConfig slice for an @sigx/ssg theme.

See SSG integration.

@sigx/mermaid/styles#

The cosmetic stylesheet. Everything functional is done in JS with the hidden attribute, so a site that skips it still behaves correctly. Override the custom properties on .sigx-mermaid — see Styling.