Skip to content
ContentMermaidMenu

Mermaid

Mermaid diagrams in the chatcn palette, with source view, zoom, pan and fullscreen. Mermaid loads on first use.

A flowchart in the chatcn palette, with source, zoom and fullscreen.

Installation

$ pnpm dlx shadcn@latest add https://chatcn.dev/r/mermaid.json

Usage

tsx
import { Mermaid } from "@/components/ui/chatcn/mermaid"

<Mermaid title="Webhook pipeline" chart={source} />

Colors come from the chatcn tokens where the diagram lives, so scoped themes work, and the diagram re-renders when the theme changes.

Examples

Streaming and errors

A sequence diagram streaming as source, then rendering, and a syntax error.

Props

PropTypeNotes
chartstringMermaid source
titlestringHeader label and accessible name. Default Diagram
streamingbooleanShows the source and renders once complete
defaultView"diagram" | "source"Starting view

Keyboard

KeyAction
+, -Zoom the focused diagram
0Reset the view
Arrow keysPan
Ctrl or Cmd plus wheelZoom at the pointer. A plain wheel scrolls the page
EscLeave fullscreen

Accessibility

  • The diagram is an image labeled with its title; the source view gives the same content as text.
  • Syntax errors explain what happened and show the source.

Motion

  • Zoom buttons ease over 200 ms. Dragging, the wheel and keys move the view directly. Under reduced motion nothing eases.
  • Fullscreen uses the Dialog motion.