https://discord.umbraco.com logo
A Practical Guide to SVGs in Umbraco
# news
m
Morning all finally got round to blogging about SVGs!!! A Practical Guide to SVGs in Umbraco https://dev.to/matthewwise/a-practical-guide-to-svgs-in-umbraco-1gm6
s
Was this related to this discussion at all? And maybe you have thoughts on that one? https://github.com/umbraco/Umbraco-CMS/discussions/22114
m
hadnt seen it but will take a look ๐Ÿ˜„
Interesting I actaully "stole" the width/height viewbox code form Our TagHelpers with the same assume as yourself viewBox is the internal size and its infinate so why do we want width height... I wonder if @Andy Boot can remeber why he added it to TagHelpers ๐Ÿ˜„
a
Now you're asking me to think back... ๐Ÿ˜… From what I remember, SVGs can be supplied or generated with width and height attributes instead of a viewBox. When thatโ€™s the case, the SVG effectively has a fixed size unless CSS overrides it. Using a viewBox is generally the better approach, as it allows the SVG to scale naturally with its HTML container. Since we already have the values from the width and height attributes, the tag helper simply normalises all SVGs by adding a viewBox, even if one isnโ€™t already present.
26 Views