Transparency removes the page behind an image; it does not make the image's colors adapt.
One drawing needs two intentional color systems
The blog's light and dark pages use different background, text, muted, and accent colors. A diagram with a transparent background can reveal the page surface underneath, but its labels and edges keep the colors that were baked into the SVG. Light gray labels can disappear on a light page; dark outlines can become hard to see on a dark page. One compromise palette often looks dull in both contexts.
The article therefore declares separate lightSrc and darkSrc outputs and asks the renderer to produce each one with a palette designed for its destination. This is a simple exchange: two small static image files in return for legible diagrams across themes, without runtime filters, SVG DOM surgery, or a second renderer in the browser.
PlantUML can share structure and vary the skin
The existing PlantUML example keeps the sequence itself in article-flow.iuml. Small light and dark include files contain their skinparam values, and each .puml entry point includes the matching skin followed by the shared diagram structure. The actors, messages, and notes remain the same while font colors, borders, fills, arrows, and note surfaces change together.
The background is transparent in both versions, but every foreground role is still specified. For light mode, the diagram uses dark text and cyan-blue structure on pale surfaces. For dark mode, text becomes light, cyan edges gain prominence, and participant and note fills move to dark colors. This is an authored palette, not an automatic inversion of one finished SVG.
skinparam backgroundColor transparent
skinparam defaultFontColor #243642
skinparam ArrowColor #137F92
skinparam ParticipantBackgroundColor #E7F4F6
skinparam NoteBackgroundColor #F3F6F8
Mermaid keeps one drawing source and two theme files
The Mermaid example uses a single article-flow.mmd flowchart. The light and dark JSON theme files configure the same diagram syntax with different background, primary, secondary, tertiary, line, border, and text colors. The build invokes mmdc once for each theme, passing the same source and a different theme file each time. It writes two transparent-background SVGs to the declared paths.
This is a useful way to separate a diagram's structure from its palette. PlantUML can do the same with shared includes and separate entry points; Mermaid's CLI exposes theme configuration as JSON. The author should choose whichever source layout is clear for the particular tool, while keeping each output path explicit in the article declaration.
{
"theme": "base",
"themeVariables": {
"darkMode": true,
"background": "#171c20",
"primaryColor": "#24353b",
"primaryTextColor": "#e8eef2",
"primaryBorderColor": "#70c7d2",
"lineColor": "#70c7d2",
"textColor": "#e8eef2"
}
}
ThemeImage is generic presentation behavior
The blog's Image section recognizes the lightSrc and darkSrc pair and delegates rendering to the framework's text.html.ThemeImage component. That component emits one figure containing two image elements and one escaped caption. Both images have the same alt text and dimensions, and both use lazy loading and asynchronous decoding. The page's theme-image stylesheet is returned as a style-slot dependency by the shared HTML component contract.
The CSS is declared with the framework's text.css.ThemeImage rules and written as a component stylesheet during the site build. When the root html element has data-theme="light", the dark image is hidden; when it has data-theme="dark", the light image is hidden. If the page has no explicit data-theme attribute, prefers-color-scheme selects the visible variant. Changing the site's existing theme preference changes which image is displayed without rerendering the article or requesting a diagram engine.
- type: image
lightSrc: articles/2026/10/diagrams/flow-light.svg
darkSrc: articles/2026/10/diagrams/flow-dark.svg
width: 1060
height: 322
alt:
en: A flowchart of the publishing stages
es: Un diagrama de las etapas de publicación
caption:
en: The selected picture follows the page theme.
es: La imagen elegida sigue el tema de la página.
Accessibility and failure output stay with the image
The image section still requires localized alternative text and a localized caption. The alt text describes what the diagram communicates rather than its color palette; the caption can explain why two outputs exist. Width and height reserve the same shape for both variants, while the stylesheet makes the images responsive without distorting their aspect ratio.
If either renderer fails, the diagram preparer attaches its complete diagnostic to the section. ThemeImage then displays an escaped status message instead of both image elements, while retaining the caption and stylesheet dependency. That behavior makes a missing diagram obvious in the Writing Studio preview and in a local build without turning the rest of the article into a broken page.
The pattern is not PlantUML-specific or Mermaid-specific. Any static image that genuinely needs a different design for light and dark surfaces can use the same lightSrc/darkSrc contract. The component owns selection and responsive presentation; the article owns the visual assets and the meaning communicated by the diagram.
