SVG with uri rendering larger than container and are cropped
See original GitHub issueBug
SvgUri is rendering the SVG but not containing it within the size specified.
Environment info
React native info output:
React Native Environment Info:
System:
OS: macOS 10.15.1
CPU: (8) x64 Intel(R) Core(TM) i7-4980HQ CPU @ 2.80GHz
Memory: 311.12 MB / 16.00 GB
Shell: 5.7.1 - /bin/zsh
Binaries:
Node: 12.8.1 - /usr/local/bin/node
Yarn: 1.17.3 - /usr/local/bin/yarn
npm: 6.12.0 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1
Android SDK:
API Levels: 23, 25, 26, 28
Build Tools: 22.0.1, 23.0.1, 23.0.3, 25.0.2, 26.0.1, 26.0.3, 28.0.1, 28.0.3
System Images: android-23 | Intel x86 Atom_64, android-23 | Google APIs Intel x86 Atom_64, android-28 | Google APIs Intel x86 Atom
IDEs:
Android Studio: 3.1 AI-173.4819257
Xcode: 11.2.1/11B500 - /usr/bin/xcodebuild
npmPackages:
react: 16.8.3 => 16.8.3
react-native: ^0.59.8 => 0.59.10
npmGlobalPackages:
create-react-native-app: 1.0.0
react-native-app-id: 0.0.5
react-native-git-upgrade: 0.2.7
Library version: x.x.x
Steps To Reproduce
<SvgCssUri width="100px" height="100px" uri={source} />
or
<SvgUri width="100px" height="100px" uri={source} />
I’d like for the SVG to be contained within the size specified, otherwise what’s the point. Currently the image is cropped. The screenshot below should be of the linux penguin.
Reproducible sample code
see above
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:14
Top Results From Across the Web
SVG with uri rendering larger than container and are cropped
Bug SvgUri is rendering the SVG but not containing it within the size specified. Environment info React native info output: React Native ...
Read more >Scale SVG to container without mask/crop - Stack Overflow
The aspect ratio described by your viewBox will be preserved when rendering. By comparison, a value of none would allow non-uniform scaling. The...
Read more >Scaling of SVG backgrounds - CSS: Cascading Style Sheets
If none of the above cases are met, the image is rendered at the same size as the background area. It's worth noting...
Read more >How to Scale SVG | CSS-Tricks
You can force the browser to draw a raster image at a different size than its intrinsic height and width, but if you...
Read more >Cropping & Scaling Images Using SVG Documents
And you want to make it possible for them to upload any image of any size and aspect ratio, and then you'd handle...
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
This is using a URI, though.
Hi, I’m also facing a similar issue where the format of the SVG is all over the place, some don’t have viewboxes and some do but still get cropped. How would you achieve what you’re talking about here. I’m just trying to display an external SVG in a container with some padding so width=“100%” and height=“100%”