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.

Will components inside SVG be supported?

See original GitHub issue

Currently elements inside the components template seems to be rendering using the xhtml name-space and is not showing up on the screen. I realize Angular 2 is in an early stage but I wanted to know if this scenario is on the track at all.

I.E. this is the usecase i mean:

<svg>
  <my-component></my-component>
</svg>

Issue Analytics

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

github_iconTop GitHub Comments

9reactions
MonkeyDocommented, Feb 20, 2016

Same here, this is a feature I would love to see on the map. For now the g[attribute] solution will have to do.

My use case is reusable components that generate svg programatically (using D3, ported from another project) and that I would like to use both in regular html and in svg elements.

For example:

<gauge-component>
    <svg>…</svg>
</gauge-component>

<svg>
    <gauge-component>
        <svg>…</svg>
    </gauge-component>
    <gauge-component>
        <svg>…</svg>
    </gauge-component>
</svg>
6reactions
stijmeercommented, Jan 12, 2017

I just found this great article explaining how to use svg-components with angular 2!

You will have to namespace the svg elements and use an attribute selector for the component:

@Component({
  selector: '[app-logo-left]',
  templateUrl: './app-logo-left-component.html'
})
<svg viewBox="0 0 250 250">
  <svg:g app-logo-left />
  <svg:g app-logo-right />
  <svg:g app-logo-a />
</svg>
Read more comments on GitHub >

github_iconTop Results From Across the Web

SVG: Scalable Vector Graphics - MDN Web Docs - Mozilla
Chrome Edge svg Full support. Chrome1. Toggle history Full support. Edge... baseProfile. Deprecated Full support. ChromeYes. Toggle history Full support. Edge... contentScriptType. Deprecated No support. ChromeNo....
Read more >
Building SVG Components with React.js and d3.js - pganalyze
The mechanics of using SVG elements in React are straightforward: Just write a standard component and return an SVG tag instead of an...
Read more >
Working with SVGs in React - Ross Bulat - Medium
Being able to embed SVG CSS properties within React components is perhaps the most efficient means of styling an SVG via CSS, offering...
Read more >
Can we render Angular components inside of our SVG ...
If you do component selector with tags, than SVG schmema is broken and browser won't be able to render SVG. Using group (which...
Read more >
How to use SVGs in React - LogRocket Blog
Today, a huge percentage of icon libraries, such as Flaticon, Font Awesome, Material Icon, etc., have full support for SVG. Brands such as ......
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