Svg does not respect container width/height
See original GitHub issueSvg renders at full size always and does not scale down to fit the container size. In this case below, svg cannot be seen because it has rendered outside 100x100 area.
<Canvas style={{height: 100, width: 100}}>
{source && (
<ImageSVG
height={100}
width={100}
x={0}
y={0}
source={source}
/>
)}
</Canvas>
Issue Analytics
- State:
- Created 2 years ago
- Comments:7
Top Results From Across the Web
How can I make an svg scale with its parent container?
Notice how I set only width, no height. I set it to 100% so it fills the container it is in. This is...
Read more >How to make an svg scale with its parent container
The SVG element occupies 100% width of the parent container and its height is auto-adjusted depending on screen size. We use viewBox to...
Read more >How to Scale SVG | CSS-Tricks
SVG images, in contrast, can be drawn at any pixel size, so they don't need a clearly defined height or width. And they...
Read more >SVG in <img> without viewBox and with CSS height/width ...
> I'd expect height and width on an <iframe> to cause the contents to become > scrollable if they don't fit, whether it...
Read more >SVG sizing - Google Docs
With user agent style 100% width/height the size would be the same as long as the container has auto-height (and the SVG doesn't...
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 Free
Top 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
Couldn’t agree more. React Native Skia should be a foundation for others to extend on - and the SVG rendering looks like a very good candidate for building a library.
@chrfalch I completely agree with you on this. This will require parsing the dom on JS side or Native then resizing according to the container with so the svg can fit properly. This will require extra maintainence and also increase the bundle size when if add any html parser to do this.
But the problem is that the usefulness of svg support becomes very limited without this since mobile devices are small and will require scaling things down like images and svgs.
One way is to not do it yourself from ground up but instead use an external dependency to handle resizing the svg on JS side.
Or hope that someone makes a library that uses react-native-skia to render svgs with resizing support. That you can you focus on the core parts.
I think that this library is more like a canvas in browser that gives you what is needed to build what you want. But it really depends on you, the devs. It can be an all in one solution for graphics too.