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.

Support for "currentColor" and "inherit" color values.

See original GitHub issue

I 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:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

0reactions
VincentCATILLONcommented, Jan 4, 2019

For those searching for a way to use react-native-svg (version 6.x and below) with SVG containing currentColor or inherit value in fill attribute.

Let’s take a look at this PR which replaces currentColor (or inherit) values by reference to props.color and so emulate the currentColor behaviour.

https://github.com/CoorpAcademy/components/pull/1436/files#diff-90ea253cb3ce7782845a01a0787e17c0R82

Enjoy 🙌

Read more comments on GitHub >

github_iconTop 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 >

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