Author diagrams

Scale exact geometry without layout shift

Reserve the aspect ratio, preserve the viewBox, and keep rotated labels and ports stable.

sheet
7 / 14
rev
v0.5
sections
2
compiled
2

01 / LayoutReserve the canvas before SVG arrives

The compiler emits explicit width, height, and viewBox, so the page can reserve the exact space the vector will occupy before it arrives. Give the host the same aspect-ratio and cumulative layout shift goes to zero — the diagram is bounded before it is parsed, and this is where that pays.

.schemd-frame {
	aspect-ratio: 840 / 360;
	contain: layout paint;
}
.schemd-frame > svg {
	display: block;
	inline-size: 100%;
	block-size: auto;
}
source:IN "AC" at (80, 120) #blue [type=voltage-ac]
resistor:R "R" right-of IN by 120 #amber
junction:J "node" right-of R by 120 #cyan
capacitor:C "C" below J by 80 aligned-x with J #cyan [orientation=down]
port:OUT "out" right-of J by 190 #emerald

IN.positive -> R.in #blue [line]
R.out -> J.node #amber [line]
J.node -> C.in #cyan [ortho]
J.node -> OUT.in #emerald [line]
compiled by @schemd/core → shown in the rail

Labels are emitted outside the rotated vector group, so text stays upright at every viewport size while full-mode port hotspots stay aligned with the terminals they belong to. Scaling changes how large the drawing is, never what it says.

02 / PerformanceContain expensive host repaint

Reach for content-visibility: auto on a long gallery, with contain-intrinsic-size as the placeholder. And do not animate an SVG d string to move a panel — transform or fade the container instead. Path animation forces geometry work on every frame for motion the geometry was never part of.

logic:HI "1" at (90, 120) #blue [type=high]
buffer:B "buffer" right-of HI by 160 #cyan [type=schmitt]
load:L "lamp" right-of B by 170 #emerald [type=lamp]

HI.out -> B.in1 #blue [digital line]
B.out1 -> L.in #emerald [line]
compiled by @schemd/core → shown in the rail