Hand-authored, theme-aware vector art that scales crisply and respects dark/light. For relationship diagrams, reach for π§ MermaidGuru first.
1. π― When
| Pick SVG | Pick Mermaid |
|---|---|
| Precise custom shapes, icons, badges | Auto-laid flow / sequence / state |
| Exact pixel control / brand marks | βJust show the relationshipβ |
| Annotated diagrams, gauges, legends | Graph that changes often |
| Non-graph illustration | ER / mindmap structure |
Rule of thumb: if a layout engine should place the boxes, use π§ MermaidGuru. If you place every point, use SVG.
2. π viewBox
viewBoxdefines the coordinate space; width/height (or CSS) define the rendered size. UseviewBoxfor resolution independence β never bake in pixelwidth/heightalone.
<svg viewBox="0 0 100 100" role="img" aria-labelledby="t d">
<title id="t">Status badge</title>
<desc id="d">Green check inside a ring</desc>
<circle cx="50" cy="50" r="44" fill="none" stroke="currentColor" stroke-width="6" />
<path
d="M30 52 L45 67 L72 36"
fill="none"
stroke="currentColor"
stroke-width="8"
stroke-linecap="round"
stroke-linejoin="round"
/>
</svg>3. π Theme
The site is theme-adaptive β make SVG follow suit instead of freezing colors (same spirit as π SSOT Bible Β§4 for Mermaid).
- π¨
fill="currentColor"/stroke="currentColor"inherits the surrounding text color, so the art flips with the theme automatically. - π§ͺ For accents, reference site CSS variables:
fill="var(--secondary)",stroke="var(--tertiary)". Provide a sane literal fallback only where a var may be absent. - π« Avoid hardcoded
#fff/#000β they break in one of the two themes.
4. βΏ A11y
- π·οΈ Add
role="img"+<title>(and<desc>for detail), wired viaaria-labelledby="t d". - π Purely decorative SVG β
aria-hidden="true"and drop the title. - π€ Keep real labels as
<text>(selectable, themeable) rather than outlined paths.
5. π©Ή Fixes
- Invisible in light mode β hardcoded dark fill; switch to
currentColor/var(). - Blurry when scaled β missing
viewBox; add it, drop fixed pixel sizing. - Clipped edges β content exceeds
viewBox; widen the box, not the element. - No screen-reader text β add
role="img"+<title>.
Need flow, not freehand? β π§ MermaidGuru. Spatial maps β πΊοΈ CanvasGuru.