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

@unify-js/vitepress-mermaid

v1.0.0

Published

VitePress custom theme for Mermaid diagram preview with fullscreen, zoom, and pan support

Readme

@unify-js/vitepress-mermaid

A VitePress custom theme that provides fullscreen preview functionality for Mermaid diagrams, supporting zoom and drag-to-pan interactions.

Features

  • 🎯 Click to Preview - Click on Mermaid diagrams in your documentation to view them in fullscreen
  • 🔍 Free Zoom - Supports zoom in/out/reset, with convenient mouse wheel zooming
  • 🖐️ Drag to Pan - Drag to move and explore diagram details
  • 🌓 Dark Mode - Automatically adapts to VitePress dark/light themes
  • ⌨️ Keyboard Shortcuts - ESC to close, Ctrl/Cmd + +/- to zoom
  • 📱 Responsive Design - Mobile-friendly interaction experience

Choose Your Starting Point

| Scenario | Recommended Approach | Description | | -------------------------- | -------------------- | --------------------------------------------------------- | | Creating a new project | CLI Tool | Scaffold a pre-configured project with sample diagrams | | Existing VitePress project | Manual Integration | Install and configure the plugin in your existing project |

Option 1: Scaffold with CLI

Use the create-vitepress-mermaid CLI tool to create a new pre-configured project:

# npm
npm create @unify-js/vitepress-mermaid

# pnpm
pnpm create @unify-js/vitepress-mermaid

# yarn
yarn create @unify-js/vitepress-mermaid

After creation, follow the instructions to install dependencies and start the dev server:

cd <project-name>
npm install  # or pnpm install, yarn
npm run dev  # or pnpm dev, yarn dev

The generated project includes sample Mermaid diagrams and complete TypeScript configuration.

Option 2: Integrate into Existing Project

Installation

Install the plugin using your preferred package manager:

pnpm add @unify-js/vitepress-mermaid
# or
npm install @unify-js/vitepress-mermaid
# or
yarn add @unify-js/vitepress-mermaid

Dependency Requirements

This custom theme requires the following dependencies to work properly. Please make sure they are installed:

pnpm add -D vitepress mermaid

Configuration

Step 1: Configure VitePress Config

In .vitepress/config.ts:

import { defineConfig } from 'vitepress';
import { withMermaidConfig } from '@unify-js/vitepress-mermaid/config';

export default withMermaidConfig(
  defineConfig({
    // Your VitePress config
  })
);

Important: The config helper must be imported from @unify-js/vitepress-mermaid/config (with /config suffix), not from the root package. This is because VitePress config runs in Node.js, while the theme runs in the browser. Keeping them separate prevents module resolution errors.

Step 2: Configure Theme

In .vitepress/theme/index.ts:

import type { Theme } from 'vitepress';
import { MermaidTheme } from '@unify-js/vitepress-mermaid';

export default {
  extends: MermaidTheme,
} satisfies Theme;

Using in Markdown

The custom theme automatically recognizes mermaid code blocks:

```mermaid
graph TD
  A[Start] --> B{Decision}
  B -->|Condition 1| C[Process 1]
  B -->|Condition 2| D[Process 2]
  C --> E[End]
  D --> E
```

Display Source Code

Use the mermaid-example language identifier to display both the diagram and its source code:

```mermaid-example
graph LR
  A --> B --> C
```

API Reference

mermaidMarkdownPlugin

markdown-it plugin that converts mermaid code blocks to Vue components.

import { mermaidMarkdownPlugin } from '@unify-js/vitepress-mermaid';

md.use(mermaidMarkdownPlugin);

Keyboard Shortcuts

| Shortcut | Function | | -------------- | -------------------- | | ESC | Close preview window | | Ctrl/Cmd + + | Zoom in | | Ctrl/Cmd + - | Zoom out | | Ctrl/Cmd + 0 | Reset zoom | | Mouse wheel | Zoom | | Drag | Move diagram |

Requirements

  • vitepress: ^2.0.0
  • mermaid: ^11.0.0

License

MIT