Support for "currentColor" and "inherit" color values.
See original GitHub issueI have a use case where I want to define a symbol with certain inherited values, and reference it within different contexts:
<svg width="256" height="256">
<symbol id="foo">
<circle cx="128" cy="128" r="64" fill="inherit" />
</symbol>
<g fill="orange">
<use href="#foo" />
</g>
<g fill="pink">
<use href="#foo" />
</g>
</svg>
However, it appears that the inherit
and currentColor
values are not currently supported.
It seems like this could be supported on the js side by using React context, and resolving to “final” values before the bridge. However, I did see that there is already a native context for inheritance of text properties.
What would your preference be on how to implement this: introduce react context, or build off of the existing native context?
This is related to #589.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Support for "currentColor" and "inherit" color values. · Issue #764
I have a use case where I want to define a symbol with certain inherited values, and reference it within different contexts:
Read more ><color> - CSS: Cascading Style Sheets - MDN Web Docs
If currentcolor is used as the value of the color property, it instead takes its value from the inherited value of the color...
Read more >currentcolor | CSS-Tricks
[…] you can use this value to indicate you want to use the value of color for other properties that accept a color...
Read more >Extending the Color Cascade with the CSS currentColor ...
It therefore acts as the inherit value to allow inheritance of a color that would otherwise not be inherited by a property or...
Read more >What are transparent, currentcolor, and inherit keywords in ...
The transparent keyword in CSS is used to represent a fully transparent color. With the help of this, we can set the items...
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
I have partial support here: https://github.com/react-native-community/react-native-svg/commit/1827b918833efdaa25cfc1a76df2164cb2bcdd2b
For those searching for a way to use
react-native-svg
(version 6.x and below) with SVG containingcurrentColor
orinherit
value infill
attribute.Let’s take a look at this PR which replaces
currentColor
(orinherit
) values by reference toprops.color
and so emulate thecurrentColor
behaviour.https://github.com/CoorpAcademy/components/pull/1436/files#diff-90ea253cb3ce7782845a01a0787e17c0R82
Enjoy 🙌