question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add viewbox attribute

See original GitHub issue

Please add viewbox attribute to the SVG element, and allow to pass it as an optional @Input. Without viewbox SVGs don’t scale along with their parent container, but remain fixed to their defines width/height.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
AsafAgranatcommented, Sep 23, 2019

My use case was, that i used an SVG directly from a Wikimedia URL, and that SVG rendered without a viewbox attribute. Not having an intermediary method to include the viewbox, i had to resolve to either download the file first, or apply an attribute on runtime, both of which solution defeat the purpose of having a convenient library to do it, in my opinion.

0reactions
czeckdcommented, Mar 6, 2020

@AsafAgranat, @bladeski angular-svg-icon@9.1.0 now has a means to set the viewBox. Here’s the documentation from the readme:

[viewBox] - An optional string to set the viewBox on the SVG. If the viewBox=“auto”, then svg-icon will attempt to convert the SVG’s width and height attributes to a viewBox=“0 0 w h”. Both explicitly setting the viewBox or auto setting the viewBox will remove the SVG’s width and height attributes.

Read more comments on GitHub >

github_iconTop Results From Across the Web

viewBox - SVG: Scalable Vector Graphics - MDN Web Docs
The viewBox attribute defines the position and dimension, in user space, of an SVG viewport. The value of the viewBox attribute is a...
Read more >
SVG viewBox Attribute - GeeksforGeeks
The viewBox is an attribute of the SVG element in HTML. It is used to scale the SVG element that means we can...
Read more >
SVG Viewport and viewBox (For Complete Beginners)
Control the viewBox by adding the attribute viewBox to the svg element. It can also be used on the elements symbol , marker...
Read more >
How can I set a viewBox on an SVG element created with ...
You have to use document.createElementNS("http://www.w3.org/2000/svg", "svg") instead of document.createElement('svg'). document.
Read more >
Art-Directing SVG Images With The viewBox Attribute
The viewBox attribute is used to specify the origin and dimensions of the user coordinate system of an SVG image. All the drawing...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found