npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@avol-io/react-mermaid

v0.3.1

Published

React component for rendering Mermaid diagrams with zoom, pan, and fullscreen support.

Readme

@avol-io/react-mermaid

React component that renders Mermaid diagrams with zoom, pan, directional controls, fullscreen, download, and draw.io integration.

Storybook npm license


Installation

npm install @avol-io/react-mermaid

Peer dependencies

npm install react react-dom mermaid react-zoom-pan-pinch

| Package | Required version | |---|---| | react | >=19 | | react-dom | >=19 | | mermaid | >=11 | | react-zoom-pan-pinch | >=3 |


Usage

import { MermaidDiagram } from '@avol-io/react-mermaid'

export function App() {
  return (
    <MermaidDiagram
      chart={`
        graph TD
          A[Start] --> B{Decision}
          B -- Yes --> C[Done]
          B -- No  --> D[Skip]
      `}
      width="100%"
      height="400px"
    />
  )
}

API

MermaidDiagram

| Prop | Type | Default | Description | |---|---|---|---| | chart | string | required | Mermaid source text | | width | string | "100%" | CSS width of the container | | height | string | "400px" | CSS height of the container | | config | MermaidConfig | — | Options forwarded to mermaid.initialize() | | enableDownloadSvg | boolean | true | Show "SVG" option in the download dropdown | | enableDownloadMmd | boolean | true | Show ".mmd" option in the download dropdown | | enableDrawio | boolean | true | Show "Open in draw.io" button in the toolbar |

When both enableDownloadSvg and enableDownloadMmd are false, the download dropdown button is not rendered at all.

Modal

| Prop | Type | Default | Description | |---|---|---|---| | title | string | "Error" | Modal heading | | onClose | () => void | required | Called on Escape, overlay click, or close button | | children | ReactNode | required | Modal body content |


Toolbar

Top-right

  • Download — dropdown with SVG and .mmd options (each independently toggleable via props)
  • Open in draw.io — opens app.diagrams.net with the diagram preloaded via Mermaid import URL
  • Fullscreen — toggles a fixed fullscreen overlay

Bottom-right (3×3 grid)

  • Arrow buttons — pan the diagram in all four directions
  • Center button — resets the view to fit the content in the container
  • Zoom in / Zoom out — step zoom (wheel zoom also supported, follows the cursor)

Styling

No CSS import required. On first render a <style id="avol-react-mermaid-styles"> tag is injected into <head> once and reused by all instances.

All colors and sizes are exposed as CSS custom properties. Override them on :root for a global theme, or scope to a container class for per-instance theming:

/* dark theme example */
:root {
  --mermaid-bg: #1f2937;
  --mermaid-border-color: #374151;
  --mermaid-toolbar-bg: rgba(17, 24, 39, 0.9);
  --mermaid-toolbar-color: #f9fafb;
  --mermaid-toolbar-hover-bg: #111827;
  --mermaid-toolbar-border: #4b5563;
  --mermaid-fullscreen-bg: #111827;
  --mermaid-dropdown-bg: #1f2937;
  --mermaid-dropdown-item-color: #f3f4f6;
  --mermaid-dropdown-item-hover: #374151;
}

Available tokens

| Token | Default | Controls | |---|---|---| | --mermaid-bg | transparent | container background | | --mermaid-border-color | rgba(0,0,0,0.12) | container border color | | --mermaid-border-radius | 8px | container corner radius | | --mermaid-toolbar-bg | rgba(255,255,255,0.9) | button background | | --mermaid-toolbar-border | rgba(0,0,0,0.12) | button border | | --mermaid-toolbar-color | #374151 | button icon/text color | | --mermaid-toolbar-hover-bg | #ffffff | button hover background | | --mermaid-toolbar-hover-shadow | 0 2px 8px rgba(0,0,0,0.1) | button hover shadow | | --mermaid-toolbar-focus-ring | #01696f | focus outline color | | --mermaid-toolbar-btn-size | 30px | button width & height | | --mermaid-toolbar-btn-radius | 6px | button corner radius | | --mermaid-dropdown-bg | #ffffff | dropdown panel background | | --mermaid-dropdown-border | rgba(0,0,0,0.1) | dropdown border | | --mermaid-dropdown-shadow | 0 4px 12px rgba(0,0,0,0.12) | dropdown shadow | | --mermaid-dropdown-item-hover | #f3f4f6 | dropdown item hover background | | --mermaid-dropdown-item-color | #374151 | dropdown item text color | | --mermaid-error-bg | #fef2f2 | error banner background | | --mermaid-error-border | #fecaca | error banner border | | --mermaid-error-color | #dc2626 | error banner text | | --mermaid-fullscreen-bg | #ffffff | fullscreen overlay background | | --mermaid-fullscreen-zindex | 9998 | fullscreen z-index |


Live docs

https://www.avol.io/react-mermaid/


License

MIT © avol.io