Diagram
<quiet-diagram>
Renders flowcharts, sequence diagrams, and many other diagram types from text written in Mermaid syntax. Reach for it when you want diagrams that live alongside your content as code and adapt to light and dark mode.
Diagrams are drawn by , a small renderer that reads syntax and outputs SVG using its own layout engine. Each diagram type loads on demand, so you'll never fetch the ones you don't use. Text, lines, and shapes are colored with the theme's design tokens, so they'll follow your theme. Categories such as pie slices use the same fixed palette as charts.
<div id="diagram__overview">
<quiet-diagram label="A flowchart showing how a cat decides what to do next">
flowchart LR
wake[Wake up] --> hungry{Hungry?}
hungry -- Yes --> eat[Eat]
hungry -- No --> nap[Nap]
eat --> nap
</quiet-diagram>
<br>
<quiet-text-area label="Source" rows="6"></quiet-text-area>
</div>
<script type="module">
import { allDefined } from '/dist/quiet.js';
await allDefined();
const container = document.getElementById('diagram__overview');
const diagram = container.querySelector('quiet-diagram');
const textArea = container.querySelector('quiet-text-area');
// Start with the slotted source
textArea.value = diagram.code;
textArea.addEventListener('quiet-input', () => {
diagram.code = textArea.value;
});
</script>
<style>
#diagram__overview {
quiet-text-area::part(text-box) {
font-family: var(--quiet-font-family-code);
}
}
</style>
The source will be dedented automatically, so feel free to indent it naturally in your markup. Refer to the Mermaid to learn the syntax for each diagram type.
Examples Jump to heading
Providing a diagram Jump to heading
Place the diagram's source inside the component. Like the content of a <pre> tag, it will
be read exactly as written, so encode < as < and & as
& when the source contains them. Arrows such as --> don't need to be
encoded.
<quiet-diagram label="A flowchart showing a cat knocking a glass off a table">
flowchart TD
glass[Glass on table] --> stare[Maintain eye contact]
stare --> push[Push glass]
push --> floor[Glass on floor]
</quiet-diagram>
Diagram types Jump to heading
The first line of the source determines the type of diagram. The most common types are shown below, each with a link to its syntax. Every diagram type built into Mermaid is available, but some features work than they do in Mermaid's own renderer.
Flowcharts Jump to heading
connect nodes with edges. Nodes come in many shapes, edges can be labeled, and related nodes can be grouped into subgraphs.
<quiet-diagram label="A flowchart showing where a newly adopted cat naps">
flowchart LR
adopt([Adopt a cat]) --> bed{Likes the new bed?}
bed -- Yes --> nap[Nap in the bed]
bed -- No --> box[Nap in the box]
subgraph Home
nap
box
end
</quiet-diagram>
Sequence diagrams Jump to heading
Sequence show messages passing between participants over time, with support for notes, activations, alternatives, and loops.
<quiet-diagram label="A sequence diagram showing a human calling a cat">
sequenceDiagram
actor Human
participant Cat
Human->>+Cat: Call name
Note right of Cat: Pretends not to hear
alt Treat offered
Cat-->>-Human: Arrives instantly
else No treat
Cat-->>Human: Ignores
end
</quiet-diagram>
Class diagrams Jump to heading
Class
describe classes, their members, and how they relate. Note that the inheritance arrow contains a
<, so it's encoded as <.
<quiet-diagram label="A class diagram showing that a kitten is a cat">
classDiagram
class Cat {
+String name
+int lives
+meow() void
}
class Kitten {
+play() void
}
Cat <|-- Kitten
</quiet-diagram>
State diagrams Jump to heading
State show the states something can be in and the transitions between them. States can be nested and annotated with notes.
<quiet-diagram label="A state diagram showing the states of a cat">
stateDiagram-v2
[*] --> Awake
state Awake {
[*] --> Eating
Eating --> Playing
}
Awake --> Asleep
note right of Asleep : 16 hours a day
Asleep --> [*]
</quiet-diagram>
Entity relationship diagrams Jump to heading
Entity relationship model entities, their attributes, and the relationships between them.
<quiet-diagram label="An entity relationship diagram showing that a cat owns many toys">
erDiagram
CAT ||--o{ TOY : owns
CAT {
string name
int age
}
TOY {
string kind
}
</quiet-diagram>
Gantt charts Jump to heading
Gantt plot tasks on a schedule. Tasks can be grouped into sections and marked as done, active, or critical.
<quiet-diagram label="A Gantt chart showing a cat care schedule">
gantt
title Cat care schedule
dateFormat YYYY-MM-DD
section Morning
Breakfast :done, breakfast, 2026-01-01, 1d
Grooming :active, grooming, after breakfast, 2d
section Evening
Vet visit :crit, vet, 2026-01-03, 1d
Zoomies :zoomies, after vet, 2d
</quiet-diagram>
Pie charts Jump to heading
Pie show how values make up a whole.
<quiet-diagram label="A pie chart showing how cats spend their day">
pie title How cats spend the day
"Napping" : 14
"Grooming" : 4
"Zoomies" : 2
"Judging you" : 4
</quiet-diagram>
Git graphs Jump to heading
Git show commits, branches, and merges.
<quiet-diagram label="A git graph showing a treats branch being merged">
gitGraph
commit id: "Adopt cat"
commit id: "Buy litter box"
branch treats
commit id: "Buy treats"
commit id: "Hide treats"
checkout main
merge treats
commit id: "Cat finds treats"
</quiet-diagram>
Mindmaps Jump to heading
branch out from a central idea. Indentation determines the hierarchy.
<quiet-diagram label="A mindmap of the things cats care about">
mindmap
root((Cat))
Food
Kibble
Tuna
Play
Laser
Box
Sleep
Sunbeam
</quiet-diagram>
Timelines Jump to heading
list events in the order they happen.
<quiet-diagram label="A timeline of a day in the life of a cat">
timeline
title A day in the life
Morning : Breakfast : Nap
Afternoon : Bird watching
Evening : Dinner : Zoomies
</quiet-diagram>
XY charts Jump to heading
XY
plot bars and lines on a pair of axes. For more advanced charts with tooltips, legends, and animations, you
can use <quiet-chart> instead.
<quiet-diagram label="A chart showing the number of meals and naps each day">
xychart-beta
title "Meals and naps per day"
x-axis [Mon, Tue, Wed, Thu, Fri]
y-axis "Count" 0 --> 10
bar [2, 3, 5, 6, 4]
line [5, 6, 8, 9, 7]
</quiet-diagram>
Kanban boards Jump to heading
Kanban organize tasks into columns.
<quiet-diagram label="A kanban board of cat chores">
kanban
Todo
[Buy treats]
[Clean litter box]
Doing
[Nap]
Done
[Breakfast]
</quiet-diagram>
Other types include user journeys, quadrant charts, Sankey diagrams, radar charts, treemaps, and more. Browse the Pele to see them all.
Adding a label Jump to heading
Use the label attribute to describe the diagram to assistive devices. In the same way that
images require alt text, you should add a label to every diagram. The label won't be displayed,
but it will be announced by assistive devices.
<quiet-diagram label="A flowchart showing that every path leads to a nap">
flowchart LR
play[Play] --> nap[Nap]
eat[Eat] --> nap
</quiet-diagram>
If you omit the label, the title set with Mermaid's accTitle keyword will be used instead.
Adding a title Jump to heading
To show a title above the diagram, add a title to the frontmatter at the top of the source.
Some diagram types, such as pie charts, also accept a title in their own syntax.
<quiet-diagram label="A flowchart of a cat's bedtime routine">
---
title: Bedtime routine
---
flowchart LR
yawn[Yawn] --> knead[Knead the blanket] --> sleep[Sleep on your face]
</quiet-diagram>
Changing the direction Jump to heading
A diagram's direction is part of its source. In a flowchart, the keyword after flowchart sets
it: LR for left to right, RL for right to left, TD for top down, or
BT for bottom to top. Other diagram types that support it use a
direction statement.
<quiet-diagram label="A flowchart that runs from right to left">
flowchart RL
nap[Nap] --> snack[Snack] --> zoomies[Zoomies]
</quiet-diagram>
<quiet-diagram label="A flowchart that runs from top to bottom">
flowchart TD
nap[Nap] --> snack[Snack] --> zoomies[Zoomies]
</quiet-diagram>
By default, a diagram will keep the direction written in its source and scale down to fit when it's wider
than its container. Add the with-reflow attribute to let a horizontal diagram switch to a
vertical layout when it's wider than its container and the container is narrower than 640 pixels. To let
users enlarge a diagram that's been scaled down, you can make it zoomable.
<quiet-diagram label="A flowchart that reflows in narrow containers" with-reflow>
flowchart LR
hear[Hear can opener] --> run[Run to kitchen]
run --> wait[Wait impatiently]
wait --> eat[Eat]
eat --> leave[Leave without saying thanks]
</quiet-diagram>
To change the width at which diagrams reflow, set directionBreakpoint using the
options property.
Changing the size Jump to heading
Diagrams are sized relative to the current font size. To change their size, you can apply
font-size to the diagram or an ancestor element.
<quiet-diagram label="A small flowchart" style="font-size: 0.75rem;">
flowchart LR
cat[Cat] --> box[Box]
</quiet-diagram>
<quiet-diagram label="A large flowchart" style="font-size: 1.25rem;">
flowchart LR
cat[Cat] --> box[Box]
</quiet-diagram>
Changing the font Jump to heading
Diagrams inherit their font, so you can apply font-family to the diagram or an ancestor element
to change it. Use the --title-font-weight, --heading-font-weight, and
--bold-font-weight custom properties to change the weight of titles, headings, and bold text.
Labels are measured when the diagram renders. If the font or font size changes afterwards, you can call the
refresh() method to render the diagram again.
<quiet-diagram
label="A class diagram of a cat"
style="font-family: Georgia, serif; --title-font-weight: normal; --heading-font-weight: normal;"
>
---
title: House cat
---
classDiagram
class Cat {
+String name
+nap()
}
</quiet-diagram>
Text that's drawn in monospace will use the theme's code font. To change it, set
--quiet-font-family-code on the diagram.
Zooming Jump to heading
Add the zoomable attribute to let users zoom and pan the diagram. This is useful for large
diagrams that get scaled down to fit their container. Users can zoom with the controls, by pinching, by
scrolling while holding
<quiet-diagram label="A flowchart of a cat's morning routine" zoomable id="diagram__zooming">
flowchart LR
wake[Wake up at 5 AM] --> human[Wake up human]
human --> breakfast[Demand breakfast]
breakfast --> inspect[Inspect the bowl]
inspect --> eat[Eat three bites]
eat --> groom[Groom]
groom --> window[Watch birds]
window --> sunbeam[Find a sunbeam]
sunbeam --> nap[Nap until noon]
</quiet-diagram>
<style>
#diagram__zooming {
&::part(diagram) {
padding: 1rem;
border: var(--quiet-border-style) var(--quiet-border-width) var(--quiet-neutral-stroke-soft);
border-radius: var(--quiet-border-radius-lg);
}
}
</style>
A zoomed diagram will fill the diagram part, so you can apply borders and padding there to
frame the area users zoom and pan within. Adding a min-height will give users more room.
The zoom level is relative to the diagram's natural size. A diagram that's scaled down to fit its container will start below 100%.
Removing zoom controls Jump to heading
Add the without-controls attribute to remove the zoom controls. Users will still be able to
zoom with gestures and the keyboard.
<quiet-diagram
label="A flowchart of a cat's evening routine"
zoomable
without-controls
id="diagram__without-controls"
>
flowchart LR
dinner[Demand dinner] --> zoomies[Midnight zoomies]
zoomies --> knock[Knock things over]
knock --> bed[Claim the whole bed]
</quiet-diagram>
<style>
#diagram__without-controls {
&::part(diagram) {
padding: 1rem;
border: var(--quiet-border-style) var(--quiet-border-width) var(--quiet-neutral-stroke-soft);
border-radius: var(--quiet-border-radius-lg);
}
}
</style>
Controlling zoom programmatically Jump to heading
You can call the zoomIn(), zoomOut(), zoomTo(), and
resetZoom() methods to change the zoom of a zoomable diagram, which is useful for building your
own controls. Listen for the quiet-zoom-change event to respond when the zoom level changes.
The current level is available in event.detail.zoom and through the readonly
zoom property.
<div id="diagram__zoom">
<quiet-diagram label="A flowchart of a cat exploring a cardboard box" zoomable without-controls>
flowchart LR
box[Cardboard box arrives] --> sniff[Sniff it]
sniff --> sit[Sit in it]
sit --> ignore[Ignore expensive cat bed]
</quiet-diagram>
<div>
<quiet-button-group label="Zoom">
<quiet-button data-action="zoom-out">Zoom out</quiet-button>
<quiet-button data-action="reset">Reset</quiet-button>
<quiet-button data-action="zoom-in">Zoom in</quiet-button>
</quiet-button-group>
<output>100%</output>
</div>
</div>
<script type="module">
import { allDefined } from '/dist/quiet.js';
await allDefined();
const container = document.getElementById('diagram__zoom');
const diagram = container.querySelector('quiet-diagram');
const output = container.querySelector('output');
function updateOutput() {
output.textContent = `${Math.round(diagram.zoom * 100)}%`;
}
container.addEventListener('click', event => {
const button = event.target.closest('[data-action]');
if (!button) return;
if (button.dataset.action === 'zoom-in') diagram.zoomIn();
if (button.dataset.action === 'zoom-out') diagram.zoomOut();
if (button.dataset.action === 'reset') diagram.resetZoom();
});
// The event also fires when the diagram is scaled to fit its container
diagram.addEventListener('quiet-zoom-change', updateOutput);
updateOutput();
</script>
<style>
#diagram__zoom {
quiet-diagram::part(diagram) {
padding: 1rem;
border: var(--quiet-border-style) var(--quiet-border-width) var(--quiet-neutral-stroke-soft);
border-radius: var(--quiet-border-radius-lg);
}
div {
display: flex;
align-items: center;
gap: 0.75rem;
margin-block-start: 1rem;
}
output {
color: var(--quiet-text-muted);
font-variant-numeric: tabular-nums;
}
}
</style>
Light and dark mode Jump to heading
Diagrams will follow the surrounding theme, rendering light until they're inside a
quiet-dark container. Colors will update as
soon as the theme changes, without rendering the diagram again.
<div id="diagram__dark" class="quiet-dark">
<quiet-diagram label="A flowchart shown in dark mode">
flowchart LR
lights[Lights off] --> eyes[Glowing eyes]
eyes --> pounce[Pounce on feet]
</quiet-diagram>
</div>
<style>
#diagram__dark {
padding: 1.5rem;
border-radius: var(--quiet-border-radius-md);
background-color: var(--quiet-background-color);
}
</style>
Setting the source programmatically Jump to heading
You can set the code property to provide the source with JavaScript. It will take precedence
over slotted content and it doesn't require encoding, which is useful when the source is dynamic or comes
from an API.
<div id="diagram__code">
<quiet-diagram label="A diagram of a cat's activities"></quiet-diagram>
<br>
<quiet-button>Add an activity</quiet-button>
</div>
<script>
const container = document.getElementById('diagram__code');
const diagram = container.querySelector('quiet-diagram');
const button = container.querySelector('quiet-button');
const activities = ['Nap', 'Eat', 'Groom', 'Chase laser', 'Sit in box', 'Stare at wall'];
let count = 2;
// Build a flowchart from the first few activities
function updateDiagram() {
const steps = activities.slice(0, count).map((activity, index) => `step${index}[${activity}]`);
diagram.code = `flowchart LR\n ${steps.join(' --> ')}`;
}
button.addEventListener('click', () => {
count = count >= activities.length ? 2 : count + 1;
updateDiagram();
});
updateDiagram();
</script>
Converting code blocks Jump to heading
Markdown renderers usually turn Mermaid code fences into
<pre><code class="language-mermaid"> blocks. You can replace them with
diagrams by setting the code property, which doesn't require encoding.
// Replace Mermaid code blocks with diagrams
document.querySelectorAll('pre > code.language-mermaid').forEach(code => {
const diagram = document.createElement('quiet-diagram');
diagram.code = code.textContent;
code.parentElement.replaceWith(diagram);
});
Adding links Jump to heading
Use Mermaid's click keyword to turn a node into a link. Linked nodes will show their border and
label in the theme's link color, which you can change with the --link-color custom property.
Links are limited to http, https, mailto, and tel URLs,
and scripts will be ignored.
<quiet-diagram label="A flowchart with a link to a shelter">
flowchart LR
decide[Decide to adopt] --> shelter[Find a shelter]
click shelter "https://example.com/"
</quiet-diagram>
To turn off links, set links to false using the
options property.
Styling nodes in the source Jump to heading
Mermaid's classDef, style, and linkStyle keywords style individual
nodes and edges from within the source. Colors written this way are fixed, so you can use translucent fills
such as #f59e0b33 to get tints that will work in both light and dark mode.
<quiet-diagram label="A flowchart with two highlighted nodes">
flowchart LR
nap[Nap] --> zoomies[Zoomies]:::alert --> again[Nap again]
classDef alert fill:#f59e0b33,stroke:#f59e0b
style again fill:#3b82f633,stroke:#3b82f6
linkStyle 0 stroke:#f59e0b
</quiet-diagram>
Labels on opaque fills will switch between light and dark text automatically to stay readable.
Setting a palette in the source Jump to heading
To give one diagram its own category colors, add Mermaid's palette theme variables to the frontmatter. Pie
charts use pie1 through pie8, git graphs use git0 through
git7, XY charts use a comma-separated xyChart.plotColorPalette, and timelines use
cScale0 through cScale7. Colors set this way are fixed and will take precedence
over the --series-color-* custom properties.
<quiet-diagram label="A pie chart of where a cat sleeps">
---
config:
themeVariables:
pie1: "#f472b6"
pie2: "#22d3ee"
pie3: "#a78bfa"
---
pie title Favorite napping spots
"Sunbeam" : 9
"Laundry basket" : 6
"Keyboard" : 4
</quiet-diagram>
Only the palette variables are supported. Other Mermaid theme variables won't have an effect, but you can use the custom properties to change everything else.
Adding icons Jump to heading
Mermaid's icon nodes show a named icon, e.g. cat@{ icon: "cat" }. To provide the
icons, set icons in the options property to a function that receives each name and
returns its SVG. The function can return a complete <svg> element or a series of
<path> elements that go inside one. Icons that use currentColor will match
the color of the diagram's text.
Add form to place an icon inside a square, circle, or
rounded container, h to set the node's size in pixels, and label to
show text beneath it.
<quiet-diagram label="A flowchart with cat, fish, and sleep icons" id="diagram__icons">
flowchart LR
cat@{ icon: "cat", form: "circle", h: 33 }
fish@{ icon: "fish", form: "circle", h: 33 }
nap@{ icon: "zzz", form: "circle", h: 33 }
cat --> fish --> nap
</quiet-diagram>
<script></script>
The markup returned by icons is inserted as-is. Only return markup you trust, and never build
it from the icon's name.
Passing options Jump to heading
You can set the options property to pass options through to the renderer. The most useful ones
are listed below. Refer to the
Pele
for the full list.
-
links: set tofalseto stopclickstatements from becoming links images: set tofalseto stop diagrams from loading imagesicons: a function that provides icons-
math: a function that typesets$$...$$labels using a library such as padding: the space around the diagram, in pixelsdirectionBreakpoint: the container width below which diagrams reflow, in pixels-
config: default Mermaid configuration, which frontmatter and directives in the source can override
const diagram = document.querySelector('quiet-diagram');
diagram.options = {
// Don't turn click statements into links
links: false,
// Add more space around the diagram
padding: 24
};
Options are trusted. Never build them from user input, especially icons and
math, which insert the markup they return as-is.
Rendering untrusted diagrams Jump to heading
The renderer is designed for sources written by users. Text will be escaped, scripts in
click statements will be ignored, links and images will be limited to safe URL schemes, and
oversized sources will be rejected. Images can still trigger network requests, so you can turn off images
and links when you need stricter handling. Refer to the
Pele security
for more details.
const diagram = document.querySelector('quiet-diagram');
diagram.options = {
links: false,
images: false
};
Changing the alignment Jump to heading
Diagrams are centered in their container by default. To change the alignment, set
margin-inline on the svg part.
<quiet-diagram label="A flowchart aligned to the start" id="diagram__alignment">
flowchart LR
cat[Cat] --> lap[Lap]
</quiet-diagram>
<style>
#diagram__alignment {
&::part(svg) {
margin-inline: 0 auto;
}
}
</style>
Styling diagrams Jump to heading
By default, text, lines, and shapes are colored with design tokens, and categories such as pie slices use a
fixed palette. You can use the custom properties to change the former, and
the --series-color-1 through --series-color-8 custom properties to change the
latter. Colors provided with
or adaptive tokens will theme both modes at once.
Diagrams are drawn in a shadow root, so page styles can't target individual nodes or edges. To style those, you can use keywords in the source.
<quiet-diagram label="A flowchart with custom colors" id="diagram__styling-flowchart">
flowchart LR
catnip[Catnip] --> roll[Roll around]
roll --> stare[Stare into the void]
stare --> nap[Nap]
</quiet-diagram>
<quiet-diagram label="A pie chart with custom colors" id="diagram__styling-pie">
pie title Favorite napping spots
"Sunbeam" : 9
"Laundry basket" : 6
"Keyboard" : 4
</quiet-diagram>
<style>
#diagram__styling-flowchart {
--text-color: var(--quiet-primary-text-colorful);
--line-color: var(--quiet-primary-stroke-mid);
--node-color: var(--quiet-primary-fill-softer);
--border-color: var(--quiet-primary-stroke-soft);
--border-radius: 1rem;
}
#diagram__styling-pie {
--series-color-1: light-dark(#ec4899, #f472b6);
--series-color-2: light-dark(#06b6d4, #22d3ee);
--series-color-3: light-dark(#8b5cf6, #a78bfa);
}
</style>
Some shapes draw text and gaps using the background color. If the diagram sits on a different surface,
such as a card, set --background-color to match it.
Error handling Jump to heading
When the source can't be rendered, the error will be shown in place of the diagram. If a previous version of the diagram rendered successfully, it will stay visible above the error so the page won't jump while the source is being edited.
<quiet-diagram label="A flowchart with a syntax error">
flowchart LR
cat[Cat --> box
</quiet-diagram>
Listen for the quiet-rendered and quiet-render-error events to respond when
rendering succeeds or fails. Syntax errors include line, column, and
snippet properties that point to the problem.
const diagram = document.querySelector('quiet-diagram');
diagram.addEventListener('quiet-rendered', event => {
console.log(event.detail.type, event.detail.width, event.detail.height);
});
diagram.addEventListener('quiet-render-error', event => {
console.log(event.detail.error.message, event.detail.error.line);
});
Keyboard support Jump to heading
When a diagram is zoomable, tab to it to focus it, then use the keys below.
| Key | Action |
|---|---|
| + | Zooms in |
| - | Zooms out |
| 0 Escape | Resets the zoom |
| โ โ โ โ | Pans the diagram when it's zoomed in |
API Jump to heading
Importing Jump to heading
The autoloader is the recommended way to import components but, if you prefer to do it manually, the following code snippets will be helpful.
To manually import <quiet-diagram> from the CDN, use the following code.
import 'https://cdn.quietui.org/v6.7.0/components/diagram/diagram.js';
To manually import <quiet-diagram> from a self-hosted distribution, use the following
code. Remember to replace /path/to/quiet with the appropriate local path.
import '/path/to/quiet/components/diagram/diagram.js';
Slots Jump to heading
Diagram supports the following slots. Learn more about using slots
| Name | Description |
|---|---|
| (default) |
The diagram's source in Mermaid syntax. Encode < as < and
& as & when the source contains markup or character
references. Slotted source is dedented automatically.
|
zoom-in-icon
|
The slot that contains the zoom in icon. |
zoom-out-icon
|
The slot that contains the zoom out icon. |
Properties Jump to heading
Diagram has the following properties that can be set with corresponding attributes. In many cases, the attribute's name is the same as the property's name. If an attribute is different, it will be displayed after the property. Learn more about attributes and properties
| Property | Description | Reflects | Type | Default |
|---|---|---|---|---|
code
|
The diagram's source in Mermaid syntax. When set, it takes precedence over slotted content and renders verbatim, without dedenting. Use when the source is dynamic or when escaping slotted content is impractical. |
|
string
|
|
label
|
An accessible label for the diagram. When omitted, the title provided by the source's
accTitle keyword is used instead.
|
|
string
|
''
|
zoomable
|
Lets users zoom and pan the diagram with zoom controls, pinch gestures, the mouse wheel while holding the platform modifier key, double click, and the keyboard. |
|
boolean
|
false
|
withoutControls
without-controls
|
Removes the zoom controls. Other ways of zooming still work. |
|
boolean
|
false
|
withReflow
with-reflow
|
Lets diagrams that support it switch from a horizontal layout to a vertical one when their container is narrow. By default, diagrams keep the direction written in the source. |
|
boolean
|
false
|
options
|
Options to pass through to the renderer, e.g. icons, math,
links, and config. Refer to the
Pele
for more details. The icons function may return a complete
<svg> element or only its contents. Never populate this with untrusted data.
Property only.
|
|
DiagramOptions |
undefined
|
|
zoom
|
The current zoom level relative to the diagram's natural size, e.g. 1 = 100%. Diagrams that are wider than their container are scaled down to fit, so the initial value can be less than 1. (Readonly property) |
|
number
|
Methods Jump to heading
Diagram supports the following methods. You can obtain a reference to the element and call them like functions in JavaScript. Learn more about methods
| Name | Description | Arguments |
|---|---|---|
zoomIn() |
Zooms in one step. Has no effect unless the diagram is zoomable. | |
zoomOut() |
Zooms out one step, stopping when the whole diagram is visible. Has no effect unless the diagram is zoomable. | |
zoomTo() |
Zooms to a specific level relative to the diagram's natural size, e.g. 1 = 100%. The level is limited to the range between the whole diagram being visible and 300%. Has no effect unless the diagram is zoomable. |
zoom: number
|
resetZoom() |
Resets the zoom so the whole diagram is visible. Has no effect unless the diagram is zoomable. | |
refresh() |
Renders the diagram again. Call this after something the diagram is measured with changes, such as its font or font size. |
Events Jump to heading
Diagram dispatches the following custom events. You can listen to them the same way was native events. Learn more about custom events
| Name | Description |
|---|---|
quiet-rendered |
Emitted when the diagram has been rendered after its source or options change. The diagram's type
and natural size are available in event.detail.
|
quiet-render-error |
Emitted when the diagram fails to render. The error is available in event.detail.error.
Syntax errors include line, column, and snippet properties.
|
quiet-zoom-change |
Emitted when the zoom level changes, including when a zoomable diagram is scaled to fit its
container. The new zoom level is available in event.detail.zoom.
|
CSS custom properties Jump to heading
Diagram supports the following CSS custom properties. You can style them like any other CSS property. Learn more about CSS custom properties
| Name | Description | Default |
|---|---|---|
--background-color |
The color of the surface behind the diagram. Used for text and gaps drawn on top of colored shapes, so it should match the diagram's actual background. |
var(--quiet-background-color)
|
--text-color |
The color of labels. |
var(--quiet-text-body)
|
--muted-text-color |
The color of secondary text. |
var(--quiet-text-muted)
|
--line-color |
The color of edges and arrowheads. |
var(--quiet-neutral-stroke-loud)
|
--node-color |
The fill color of nodes. |
var(--quiet-neutral-fill-softer)
|
--group-color |
The fill color of groups such as subgraphs. |
var(--quiet-neutral-fill-soft)
|
--border-color |
The border color of nodes and groups. |
light-dark(var(--quiet-neutral-300), var(--quiet-neutral-700))
|
--accent-color |
The color of highlights such as Gantt tasks. Text on top of it is drawn in the background color. |
light-dark(var(--quiet-primary-500), var(--quiet-primary-400))
|
--critical-color |
The color of critical items such as critical Gantt tasks. Text on top of it is drawn in the background color. |
light-dark(var(--quiet-destructive-500), var(--quiet-destructive-400))
|
--link-color |
The color of the border and label of nodes that link somewhere. |
var(--quiet-primary-text-colorful)
|
--border-radius |
The corner radius of rounded shapes. |
var(--quiet-border-radius-md)
|
--title-font-weight |
The font weight of the diagram's title. |
var(--quiet-font-weight-semibold)
|
--heading-font-weight |
The font weight of headings within the diagram, such as class names and section labels. |
var(--quiet-font-weight-semibold)
|
--bold-font-weight |
The font weight of bold text in labels. |
var(--quiet-font-weight-bold)
|
--series-color-1 |
The first of eight colors used for categories such as pie slices, git branches, and chart series. By default, series colors match the chart component's default palette. |
light-dark(#4a97f4, #76b0f9)
|
--series-color-2 |
The second series color. |
light-dark(#ef5655, #f8827c)
|
--series-color-3 |
The third series color. |
light-dark(#e89a26, #efb267)
|
--series-color-4 |
The fourth series color. |
light-dark(#37b995, #72c9ad)
|
--series-color-5 |
The fifth series color. |
light-dark(#927cfb, #a89cfe)
|
--series-color-6 |
The sixth series color. |
light-dark(#9abb28, #b0cb69)
|
--series-color-7 |
The seventh series color. |
light-dark(#e468b0, #ee8dc2)
|
--series-color-8 |
The eighth series color. |
light-dark(#848da0, #9fa6b5)
|
CSS parts Jump to heading
Diagram exposes internal elements that can be styled with CSS using the selectors shown below. Learn more about CSS parts
| Name | Description | CSS selector |
|---|---|---|
diagram |
The container that surrounds the rendered diagram. A zoomed diagram fills this container, so apply borders and padding here to frame the area users zoom and pan within. |
::part(diagram)
|
svg |
The rendered <svg> element. |
::part(svg)
|
error |
The error message that shows when the source can't be rendered. |
::part(error)
|
controls |
The container that surrounds zoom control buttons. |
::part(controls)
|
zoom-in-button |
The zoom in button. |
::part(zoom-in-button)
|
zoom-out-button |
The zoom out button. |
::part(zoom-out-button)
|
Custom States Jump to heading
Diagram has the following custom states. You can target them with CSS using the selectors shown below. Learn more about custom states
| Name | Description | CSS selector |
|---|---|---|
loading |
Applied while a diagram type is being loaded. |
:state(loading)
|
error |
Applied when the source can't be rendered. |
:state(error)
|
zoomed |
Applied when the diagram is zoomed in. |
:state(zoomed)
|
Dependencies Jump to heading
Diagram automatically imports the following elements. Sub-dependencies are also included in this list.