Svg loses gradients displaying a black color
See original GitHub issueBug
I’m trying to use svg’s which have some gradients, when I import them using as a file with react-native-svg-transformer I get the svg displayed but with a black color instead of keeping the defined colors/gradients. Same happens if I convert the web svg into a react-native-svg component using svgr.now.sh
Svg file:
Svg displayed on react-native:
Environment info
info Fetching system and libraries information...
System:
OS: Linux 5.0 Ubuntu 18.04.3 LTS (Bionic Beaver)
CPU: (4) x64 Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz
Memory: 2.02 GB / 7.69 GB
Shell: 4.4.20 - /bin/bash
Binaries:
Node: 10.16.2 - /usr/bin/node
npm: 6.9.0 - /usr/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
Android SDK:
API Levels: 23, 27, 28, 29
Build Tools: 23.0.1, 27.0.3, 28.0.3, 29.0.2
System Images: android-29 | Google APIs Intel x86 Atom
npmPackages:
react: 16.9.0 => 16.9.0
react-native: 0.61.2 => 0.61.2
npmGlobalPackages:
react-native-cli: 2.0.1
react-native-debugger-open: 0.3.20
Versions
"react": "16.9.0",
"react-native": "0.61.2",
"react-native-svg": "^9.11.1",
"react-native-svg-transformer": "^0.13.0"
Describe what you expected to happen:
- To see the svg displayed correctly with the default gradients and colors
Reproducible sample code with svg file and react component
https://github.com/tiagocorreiaitcenter/react-native-svg-file-test
Issue Analytics
- State:
- Created 4 years ago
- Comments:17 (1 by maintainers)
Top Results From Across the Web
Svg loses gradients displaying a black color #1153 - GitHub
I'm trying to use svg's which have some gradients, when I import them using as a file with react-native-svg-transformer I get the svg...
Read more >Why are the gradients in this SVG displaying as black?
For example, both SVGs have gradients named accend_1_ and decend_1_ . All id s need to be unique. Try giving them different ids....
Read more >Gradients in SVG - SVG: Scalable Vector Graphics | MDN
For instance, this one tells the gradient to start at the color red, change to transparent-black in the middle, and end at the...
Read more >Some SVG gradients are missing - Adobe XD: Feature Requests
I found a workaround. 1. Select the shape with the errant gradient. 2. Select the color fill in ...
Read more >Use gradients in Photoshop - Adobe Support
A noise gradient is a gradient that contains randomly distributed colors within the range of colors that you specify. ... Select the Gradient...
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
@tiagocorreiaitcenter The other svg file contains a style element with css inside it, and if you use svgr, you need to specify settings (onlyMatchedOnce to false) for the inlineStyles plugin, because the selectors in your css match more than a single element, and by default it doesn’t inline those css rules:
@neoziro Perhaps this should be made the default when setting the react-native option in svgr?
Alternatively, you can use the SvgCss element from react-native-svg like this:
Closing this issue after a prolonged period of inactivity. Fell free to reopen this issue, if this still affecting you.