Your diagram's style now travels with its code
A new %% flowgraph-theme line keeps a Mermaid diagram's Flowgraph theme inside the file, so it looks the same in a repository, in VS Code, in CI and through the API.
Mermaid code is easy to move around: paste it into a README, commit it next to the service it describes, send it to a teammate. Until now, the look you gave a diagram in Flowgraph Studio didn't move with it. The code went into the file and the theme stayed on the website, so the same diagram came out in Glass in VS Code, in whatever flowgraph.yml said in CI, and in your chosen style only on flowgraph.studio.
Now the style is part of the code. One comment line at the end of the diagram carries it:
%% flowgraph-theme: {"v":1,"presetId":"midnight","colors":{"accentColor":"#2DD4BF"}}
It holds the preset the style starts from and only what you changed, so it stays short. Mermaid treats it as a comment, so GitHub, GitLab and other Mermaid tools draw the diagram as before and ignore the line.
Where it shows up
Here's a diagram with its own line. This page draws it with the same renderer the editor uses, so you see it in its own style:
flowchart LR
checkout[Checkout] --> payments[Payments API]
payments --> ledger[(Ledger)]
payments --> events[(Payment events)]
events --> email[Receipt emails]
%% flowgraph-theme: {"v":1,"presetId":"midnight","colors":{"accentColor":"#2DD4BF"}}The same file looks the same in each of these:
- The VS Code extension draws it in that style, in its preview and in VS Code's own Markdown preview, and exports PNG and SVG in it.
- The CLI and the render API render it in that style, so a README image made in CI matches what you saw while editing.
- Flowgraph Studio gives it back its style when you open the file, paste the code or import the repository. The Style panel then shows that style, ready to change.
- AI assistants connected through the MCP server, and anything using the REST API, save the line as the diagram's style.
How to get it
Export the diagram with Export → Mermaid code and keep Style, positions and story. The file you download carries the style line along with your saved positions. In VS Code, Pull and Save into Workspace write the line for you.
If your repository already sets one theme for every diagram in flowgraph.yml, nothing changes: files without a line still use it. A line is for the diagram that needs its own look, and it wins over the repository's default.
Why a line in the code
The code is the one copy of a diagram that goes everywhere: into commits, pull requests, docs and chat. Keeping the style in it means there is nothing else to send along, nothing to get out of step, and a change of colour is a normal one-line diff in review.
It's also the groundwork for editing diagrams visually inside VS Code, which we're building now. When you change a diagram's style there, the editor will write this line, and the file will remain the only copy.
The guide Keep a diagram's style in its code lists every key the line takes and which style wins when there's more than one.
More from the blog
- Edit Mermaid diagrams visually, inside VS CodeThe Flowgraph Studio extension now opens diagrams on the website's canvas inside VS Code. Drag, connect and restyle, and every change lands in your file as plain code.
- Connect Claude to Flowgraph Studio by signing inClaude, Claude Code, Cursor and VS Code can now connect to Flowgraph Studio's MCP server with its address alone. Approve the app once, revoke it whenever you like, and no API key changes hands.
- Diagrams you draw in Flowgraph Studio, now in your READMEflowgraph sync can put a diagram saved in your account into your README, in its own theme, and keep a saved diagram in step with the code, with every change in its version history.