Feature
viewBox
The component copies the file's viewBox onto every reference. Without one, the drawing is clipped to the default box.
// SvgRegistry: the viewBox is read from the raw file once...
const viewBox = svgString.match(/viewBox="([^"]*)"/);
// ...and applied to every <fast-svg> that references the icon,
// falling back to `0 0 ${defaultSize} ${defaultSize}`.
svg.setAttribute('viewBox', viewBox?.[1] || defaultViewBox);Rules for your files
- Put a
viewBoxon the root<svg>. The firstviewBox="…"in the file, in double quotes, is used. - Start the file with the
<svg>element. An XML declaration or comment in front of it breaks parsing. - Keep internal ids unique across files. All icons share one document, so two gradients with
id="a"collide.