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.

Is it possible to resize an SVG?

See original GitHub issue

As in the title, by reading the README.md I’m not able to figure out if there is a simple way to have the SVG resized without having to manually change the various parameters.

The use case is this: I want to have an SVG image as a component (let’s call it Draw), and a screen component in which I want to import it (let’s call it App ). But I can’t know for sure the size of the View in which my Draw element will be placed, but I’d like to see the full image resized - the same way an Image would be resized. Is there a simple way to handle it?

The only “workaround” I managed to think of it the one I’ve implemented in this demo - basically, I ask the View component that will contain the SVG its dimensions and set them as the width and height of the various elements. But it seems a bit too complex, and error-prone.

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
gorangajiccommented, Nov 9, 2016

Not sure what you want to accomplish but you can use viewBox to resize svg component

https://rnplay.org/apps/CdJI3w

<Svg style={{ width: 100, height: 100 }} viewBox="0 0 50 50">
    <Circle r="25" fill="red" x={25} y={25} />
</Svg>

circle will be 50 units because element width/height is two times bigger than viewBox width/height

0reactions
kelsetcommented, Nov 10, 2016

Oh you are right - anyway thanks for the help provided 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to resize a SVG image - Medium
Open the SVG file with your text editor. It should show lines of code as below. ... As you can see, width and...
Read more >
Free Online Resize SVG Images with High output Quality
First, you need to add a SVG image file: drag & drop your SVG image file or click inside the white area to...
Read more >
Resizing SVG in html? - Stack Overflow
Open your .svg file with a text editor (it's just XML), and look for something like this at the top: <svg ... width="50px"...
Read more >
How to Scale SVG | CSS-Tricks
If you use an <object> , <embed> , or <iframe> to embed your SVG, setting height and width on the <svg> won't change...
Read more >
[2021 Tips] 3 Practical Ways to Resize SVG Files Easily - Blog
There are different ways of resizing an SVG file and one of the simplest is to resize it like a normal JPG and...
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