Skip to content

Commit f0d70dd

Browse files
committed
fix(mermaid): scale diagrams to container width (no more left-edge clip)
- Flip useMaxWidth to true and force svg width:100% - Drop flex justify-center wrapper that was pushing wide diagrams off-screen
1 parent 952f770 commit f0d70dd

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

src/components/MermaidDiagram.jsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,11 @@ const MermaidDiagram = ({ chart, theme, className }) => {
116116
theme: mermaidTheme,
117117
securityLevel: 'loose',
118118
fontFamily: preset.fontFamily,
119-
useMaxWidth: false,
119+
useMaxWidth: true,
120120
htmlLabels: true,
121121
flowchart: {
122122
padding: 15,
123-
useMaxWidth: false,
123+
useMaxWidth: true,
124124
htmlLabels: true,
125125
},
126126
themeVariables: preset.themeVariables,
@@ -168,8 +168,9 @@ const MermaidDiagram = ({ chart, theme, className }) => {
168168
<style>
169169
{`
170170
.mermaid-container svg {
171-
overflow: visible !important;
172-
max-width: none !important;
171+
display: block;
172+
width: 100% !important;
173+
max-width: 100% !important;
173174
height: auto !important;
174175
}
175176
.mermaid-container foreignObject {
@@ -181,7 +182,7 @@ const MermaidDiagram = ({ chart, theme, className }) => {
181182
`}
182183
</style>
183184
<div
184-
className="flex justify-center min-w-full"
185+
className="w-full"
185186
dangerouslySetInnerHTML={{ __html: svg }}
186187
/>
187188
</div>

0 commit comments

Comments
 (0)