Add new VS Code theme for mermaid diagrams#317617
Merged
Merged
Conversation
Fixes #316968 Creates a new theme for mermaid diagrams that is derived from the current VS Code color theme
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds a new Mermaid theme option ("vscode") that derives Mermaid themeVariables from the active VS Code color theme so diagrams update correctly when the user changes themes, including in standalone diagram editors and chat-rendered diagrams.
Changes:
- Introduces a VS Code-derived Mermaid theme (
"vscode") and makes it the default for both light and dark modes. - Injects Mermaid extension configuration into editor/chat webviews so webview-side rendering can resolve the correct theme.
- Adds a webview-side theme tracker that recomputes Mermaid
themeVariablesfrom VS Code CSS variables and triggers rerendering on theme changes.
Show a summary per file
| File | Description |
|---|---|
| extensions/mermaid-markdown-features/src/markdownMermaid/config.ts | Switches default theme to vscode and factors config-span rendering into reusable helpers. |
| extensions/mermaid-markdown-features/src/editorManager.ts | Injects the Mermaid config span into the standalone diagram editor webview HTML. |
| extensions/mermaid-markdown-features/src/chatOutputRenderer.ts | Injects the Mermaid config span into the chat output webview HTML. |
| extensions/mermaid-markdown-features/preview-src/shared/vsCodeTheme.ts | Adds the VS Code-derived Mermaid theme variable computation and DOM mutation tracking. |
| extensions/mermaid-markdown-features/preview-src/shared/index.ts | Updates defaults to vscode and centralizes Mermaid config building via the theme tracker. |
| extensions/mermaid-markdown-features/preview-src/markdown/index.ts | Rebuilds Mermaid config using the theme tracker before rerendering on preview refresh events. |
| extensions/mermaid-markdown-features/preview-src/chat/mermaidWebview.ts | Re-renders chat/editor diagrams when VS Code theme CSS variables/classes change using the new tracker. |
| extensions/mermaid-markdown-features/package.nls.json | Adds localized descriptions for the new theme option and existing theme choices. |
| extensions/mermaid-markdown-features/package.json | Adds vscode theme to settings enums (with descriptions), sets it as default, and marks notebook renderer messaging as optional. |
Copilot's findings
Comments suppressed due to low confidence (1)
extensions/mermaid-markdown-features/preview-src/shared/vsCodeTheme.ts:191
--vscode-chart-linedoes not appear to be a valid VS Code theme CSS variable (the usual pattern is--vscode-charts-lines). Because it’s listed first in the fallback chain, it may resolve to an inherited/default color and block the intended--vscode-charts-linesfallback. Please remove/fix this token name in thelineColor/border fallbacks.
// Canvas / text
set('background', '--vscode-editor-background');
set('textColor', '--vscode-charts-foreground', '--vscode-editor-foreground', '--vscode-foreground');
set('lineColor', '--vscode-chart-line', '--vscode-charts-lines', '--vscode-editor-foreground', '--vscode-foreground');
// Primary (default node) colors
set('primaryColor', '--vscode-editorWidget-background');
set('primaryTextColor', '--vscode-charts-foreground', '--vscode-editor-foreground', '--vscode-foreground');
set('primaryBorderColor', '--vscode-chart-line', '--vscode-editorWidget-border', '--vscode-focusBorder');
set('mainBkg', '--vscode-editorWidget-background');
set('nodeBorder', '--vscode-chart-line', '--vscode-editorWidget-border', '--vscode-focusBorder');
- Files reviewed: 10/10 changed files
- Comments generated: 1
Yoyokrazy
approved these changes
May 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #316968
Creates a new theme for mermaid diagrams that is derived from the current VS Code color theme
Also makes sure this works for diagrams opened in their own window and in chats