Mermaid diagrams look dated? Not anymore!
Mermaid is everywhere now: READMEs, design docs, wikis, and whatever diagram your AI assistant just generated for you. It's a great tool, but the default output looks like it's from 2012. Flat outlines, tiny text, crampe
Mermaid is everywhere now: READMEs, design docs, wikis, and whatever diagram your AI assistant just generated for you. It's a great tool, but the default output looks like it's from 2012. Flat outlines, tiny text, cramped spacing. The built-in themes only change colours.
I wanted Mermaid diagrams I'd be happy to put in a slide deck, so I built prettymaids: modern themes plus an SVG post-processor, wrapped around stock Mermaid.
You can try it right now, with nothing to install: pravin.github.io/prettymaids
The approach: keep Mermaid, restyle the output
The obvious way to get nicer diagrams is to write a new renderer. I decided against that. Mermaid's parser and layout engine handle a huge range of diagram types, and anyone with existing diagrams (or an AI tool that emits Mermaid) can keep their source unchanged.
So prettymaids leaves Mermaid alone and restyles in three layers:
- Theme variables and CSS: fonts, colours, borders, spacing.
- Per-diagram config: padding, node and rank spacing, label wrapping.
- A post-processor on the rendered SVG: the things CSS can't do.
That third layer is where most of the look comes from:
- Stacked soft drop shadows via an SVG filter
- Rounded corners on class and ER boxes, which Mermaid draws as sketch-style paths that CSS can't round
- Donut charts instead of pies, done by clipping each slice to a ring
- XMind-style mindmaps, with smooth S-curve branches that get thinner with depth and take the colour of their main topic
- An optional dot-grid canvas behind everything
Three things that went wrong
1. My "connector style" setting did nothing
I added a setting to switch edges between rounded, elbow, straight and curved. In the playground, all four looked identical.
It turns out Mermaid 12's default layout routes its own rounded orthogonal edges and ignores the flowchart.curve option entirely. Only the dagre layout honours it. So the setting now switches layout engine when you pick anything other than the default.
I only noticed because I diffed the rendered SVG instead of trusting my eyes. If a style option "works" but you've never compared the output, check it.
2. Fonts bite you twice
Mermaid measures label text when it renders, then sizes the boxes to fit. I rendered with a font that wasn't installed locally, then viewed the result on a machine that had it. The real font was wider, and labels got clipped ("Receive reques").
The fixes:
- Let labels overflow their container instead of clipping
- In the browser playground, wait for the font to load before the first render
- Install the font in CI, so the gallery renders with the real metrics
If you generate Mermaid SVGs on one machine and view them on another, this will happen to you too.
3. Different shapes need different padding
I wanted pills (terminal nodes) and decision nodes to be sized differently from ordinary boxes. But CSS can't change the box size after Mermaid has measured the text.
So flowcharts render twice. The first pass finds which nodes are pills or decisions. The second pass adds a class to each of them, so my CSS applies while Mermaid is measuring. That keeps the edges attached to the right places.
Ways to use it
In the browser: the playground has a live editor, three themes, about 28 parameters you can tune, and SVG or PNG export. The comparison gallery shows stock Mermaid next to each theme for every diagram type.
As a CLI:
npx prettymaids-cli diagram.mmd -o diagram.png
As a library:
npm install prettymaids mermaid
import mermaid from 'mermaid';
import { render, config } from 'prettymaids';
// Full look, including SVG post-processing:
const svg = await render(source, { theme: 'maid', mermaid });
// Or just the colours and typography, as a plain Mermaid config:
mermaid.initialize(config('maid'));
There are three themes: maid (light), maid-dark, and maid-flat, a lower-contrast flat look.
Honest limits
- Decision diamonds stay square. Mermaid builds them that way, and changing it means writing a custom shape.
- The CLI needs Chrome, because Mermaid needs a real browser to measure text. Installing the package downloads a Chromium for you.
- GitHub, Obsidian and Notion render Mermaid themselves, so prettymaids can't restyle diagrams inside them. Render with the CLI and commit the image.
- Nine diagram types are styled so far: flowchart, sequence, class, state, ER, gantt, pie, mindmap and git graph. Journey, timeline, quadrant and XY charts are unstyled for now.
- It's tested against Mermaid 12.3.
Try it, and tell me what's next
- Playground: https://pravin.github.io/prettymaids/
- Repo (MIT): https://github.com/pravin/prettymaids
If you try it on a diagram that comes out wrong, please open an issue and paste the Mermaid source. And if you have a view on which diagram type or look I should do next, I'd like to hear it in the comments.
Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.
