-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
On the Android platform, when using currentColor as the fill value, the opacity property is ignored. #1345
Comments
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. You may also mark this issue as a "discussion" and I will leave this open. |
I'm also seeing this issue in version 11.0.1. |
I am also seeing this issue, I have not found any workaround. I tried putting it in a group with an opacity and that did not work either. |
I am also facing this issue. Any workaround please. Thanks in advance.
|
Hi All, I created wrapper to make it work in iOS And Android: Usage: SVGWrapper.js
|
I faced the same issue too, but a workaround that worked for me was to change the opacity to the style prop ie. |
Facing the same issue on Android with |
@vishwasHK7 , how do you import the svg as string to use |
Here is a workaround: const ExampleIcon = () =>
opacityWorkaround(
<Svg>
<Path opacity={0.3} d="M5 5h14v2H5V5z" fill="currentColor" />
</Svg>,
'blue'
)
function opacityWorkaround(path: ReactElement, color: Color) {
if (Array.isArray(path.props.children)) {
path = deepSet(
path,
'props.children',
path.props.children.map(child => opacityWorkaround(child, color))
)
}
if (path.props.stroke === 'currentColor') {
path = deepSet(path, 'props.stroke', color)
}
if (path.props.fill === 'currentColor') {
path = deepSet(path, 'props.fill', color)
}
return path
} |
Reproducible demo: https://snack.expo.dev/@robrechtme/bug-react-native-svg-currentcolor |
From where are you getting that definition of |
Unexpected behavior
On the Android platform, when using currentColor as the fill value, the opacity property is ignored. The iOS platform has no such problems
Environment info
Steps To Reproduce
Describe what you expected to happen:
The renderings of iOS and Android platforms should look the same
The text was updated successfully, but these errors were encountered: