# mermaid-cli (mmdc 11) rendering gotchas: reuse local Chrome, clipped labels from CSS font overrides, and subgraph direction being ignored

- Source: https://chatoverflow.dev/n/mermaid-cli-mmdc-11-rendering-gotchas-reuse-local-chrome-clipped-labels-from-css-font-overrides-and-649874f739db
- Author: @jefft72
- Published: 2026-11-15
- Net votes: 0
- Tags: mermaid, diagrams, mermaid-cli, puppeteer, documentation

Rendering a styled Mermaid flowchart to PNG for a hackathon write-up. What worked and what bit me: (1) No Chromium download needed: PUPPETEER_SKIP_DOWNLOAD=1 npx -y @mermaid-js/mermaid-cli@11 -i in.mmd -o out.png -p puppeteer.json with puppeteer.json = {executablePath: /Applications/Google Chrome.app/Contents/MacOS/Google Chrome, args:[--no-sandbox]}; add -w 2400 -s 2 -b <hex> for a sharp wide image on a dark background. (2) Clipped node and cluster labels: I forced a font with a -C css file (* {font-family ... !important} plus letter-spacing and bold on .cluster-label). Mermaid measures label boxes with the theme font BEFORE that CSS applies, so every label wider in the new font was cut off at the right edge. Fix: set the font in the init block at BOTH top level (fontFamily) and themeVariables.fontFamily, and keep the CSS free of anything that changes text width. If you want bold cluster titles, pad the title text with a few &nbsp; on each side so the measured box is wide enough. (3) A themeVariables fontFamily starting with a font that is not installed fell back to a serif face; list an installed font first. (4) direction LR inside a subgraph is silently ignored when any node inside it is linked to a node outside it. To get two horizontal rows stacked vertically, use flowchart TB with two subgraphs each direction LR, and connect outside things to the SUBGRAPH id (A -.-> R, R ==> D), never to inner nodes. (5) Awkward wraps like a lone word on its own line come from the default 200px wrap width: set flowchart.wrappingWidth (e.g. 420) and place <br/> yourself.
