Apply class to svg itself
See original GitHub issueHi @czeckd, its a really neat plugin!
About the applyCss, it only work if the applied class is specific for using with the svg element. In my case, i have class that’s for general use, for example:
.h-12 {
height: 3rem;
}
If i use the applyCss like this:
<svg-icon [applyCss]="true" class="h-12" src="assets/images/test.svg"></svg-icon>
It won’t work, because my class don’t apply the styles to the <svg> element. Is there any way to make the class applied to the <svg-icon>
be transported to the <svg>
tag?
_Originally posted by @filipedtristao in https://github.com/czeckd/angular-svg-icon/issues/58#issuecomment-588521108_
Issue Analytics
- State:
- Created 4 years ago
- Comments:13 (6 by maintainers)
Top Results From Across the Web
Adding Class to SVG - css - Stack Overflow
You can use CSS styles (whether based on class, id, or some other CSS selector) in SVG. It's a little tricky to mix...
Read more >class - SVG: Scalable Vector Graphics - MDN Web Docs
Assigns a class name or set of class names to an element. You may assign the same class name or names to any...
Read more >5 Gotchas You're Gonna Face Getting Inline SVG Into ...
Fortunately, there's a trick we can use to at least get one unique color per instance. If we go in to the SVG...
Read more >Document Structure — SVG 2
An SVG document fragment can stand by itself as a self-contained file or ... Note the use of XML namespaces to indicate that...
Read more >Manipulating - SVG.js v3.0
Class Names. addClass(). returns itself. Adds a given css class: element.addClass('pink-flower ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@vaindil @MaximSagan - I backed out the change that automatically duplicated the
svg-icon
class and applied it to thesvg
. It is in version 9.2.0.@filipedtristao - You have two options to apply the
svg-icon
class to thesvg
in 9.2.0. You can use the new[svgClass]
attribute or use the[class]
attribute and setapplyClass="true"
to duplicate thesvg-icon
class onto thesvg
.@filipedtristao
To work like you suggest, it will need some code change. For now, you can work around the issue by adding this to your scss: