Skip to content

Conversation

@jakex7
Copy link
Member

@jakex7 jakex7 commented Dec 20, 2024

Summary

resolves #1841

Test Plan

import * as React from 'react';
import {SvgCss} from 'react-native-svg/css';

const Icon = () => (
  <SvgCss
    xml={`
      <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
        <style>.secondary{opacity:.4}</style>
        <g id="root">
          <path id="primary" d="M256 512C114.6 512 0 397.4 0 256C0 114.6 114.6 0 256 0V512z"/>
          <path class="secondary" d="M256 0C397.4 0 512 114.6 512 256C512 397.4 397.4 512 256 512V0z"/>
        </g>
      </svg>`}
    // =================================== String ===================================
    stylesheet={`
      #root {
        color: #0f0;
      }
      #primary {
        fill: #f00;
      }
      .secondary {
        fill: currentColor;
      }
    `}
    // =================================== Object ===================================
    stylesheet={{
      '#root': {
        fill: '#f00',
      },
      '#primary': {
        fill: '#f00',
      },
      '.secondary': {
        fill: 'currentColor',
      },
    }}
  />
);
export default Icon;

Checklist

  • I have tested this on a device and a simulator
  • I added documentation in README.md
  • I updated the typed files (typescript)
  • I added a test for the API in the __tests__ folder

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Is there a way to use multiple colours on a remote SVG file?

2 participants