I'm working with AppStudio. Is there a way to change SVG colors without changing the svg file or adding an overlay?
Yes, but, it depends on the QML component you use.
Some QML components implement an `icon` which can be used to scale (with resampling) and recolor SVGs, e.g.
property url bikingSvg<SPAN class="punctuation token">:</SPAN> <SPAN class="string token">"https://raw.githubusercontent.com/Esri/calcite-ui-icons/master/icons/biking-32.svg"</SPAN> ItemDelegate <SPAN class="punctuation token">{</SPAN> icon<SPAN class="punctuation token">.</SPAN>source<SPAN class="punctuation token">:</SPAN> bikingSvg icon<SPAN class="punctuation token">.</SPAN>color<SPAN class="punctuation token">:</SPAN> <SPAN class="string token">"blue"</SPAN> icon<SPAN class="punctuation token">.</SPAN>width<SPAN class="punctuation token">:</SPAN> <SPAN class="number token">32</SPAN> icon<SPAN class="punctuation token">.</SPAN>height<SPAN class="punctuation token">:</SPAN> <SPAN class="number token">32</SPAN> text<SPAN class="punctuation token">:</SPAN> <SPAN class="token function">qsTr</SPAN><SPAN class="punctuation token">(</SPAN> <SPAN class="string token">"ItemDelegate"</SPAN> <SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">}</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
You may find it useful to use the icon property in common components such as Button, ToolButton, MenuItem, e.g.
Button <SPAN class="punctuation token">{</SPAN> icon<SPAN class="punctuation token">.</SPAN>source<SPAN class="punctuation token">:</SPAN> bikingSvg icon<SPAN class="punctuation token">.</SPAN>color<SPAN class="punctuation token">:</SPAN> <SPAN class="string token">"blue"</SPAN> icon<SPAN class="punctuation token">.</SPAN>width<SPAN class="punctuation token">:</SPAN> <SPAN class="number token">32</SPAN> icon<SPAN class="punctuation token">.</SPAN>height<SPAN class="punctuation token">:</SPAN> <SPAN class="number token">32</SPAN> text<SPAN class="punctuation token">:</SPAN> <SPAN class="token function">qsTr</SPAN><SPAN class="punctuation token">(</SPAN> <SPAN class="string token">"Button"</SPAN> <SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">}</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
However, if you use Image, and you will need to take care of resampling and coloring yourself. Resampling is needed with the sourceSize property and coloring needs to be done by the ColorOverlay property. Using the Image object in this way allows you to do layering with different colors for different layers
property url bikingSvg<SPAN class="punctuation token">:</SPAN> <SPAN class="string token">"https://raw.githubusercontent.com/Esri/calcite-ui-icons/master/icons/biking-32.svg"</SPAN> property url disallowSvg<SPAN class="punctuation token">:</SPAN> <SPAN class="string token">"https://raw.githubusercontent.com/Esri/calcite-ui-icons/master/icons/circle-disallowed-32.svg"</SPAN> Item <SPAN class="punctuation token">{</SPAN> width<SPAN class="punctuation token">:</SPAN> <SPAN class="number token">32</SPAN> height<SPAN class="punctuation token">:</SPAN> <SPAN class="number token">32</SPAN> Image <SPAN class="punctuation token">{</SPAN> id<SPAN class="punctuation token">:</SPAN> bikingImage anchors<SPAN class="punctuation token">.</SPAN>fill<SPAN class="punctuation token">:</SPAN> parent source<SPAN class="punctuation token">:</SPAN> bikingSvg sourceSize<SPAN class="punctuation token">:</SPAN> Qt<SPAN class="punctuation token">.</SPAN><SPAN class="token function">size</SPAN><SPAN class="punctuation token">(</SPAN> width<SPAN class="punctuation token">,</SPAN> height <SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">}</SPAN> ColorOverlay <SPAN class="punctuation token">{</SPAN> color<SPAN class="punctuation token">:</SPAN> <SPAN class="string token">"blue"</SPAN> anchors<SPAN class="punctuation token">.</SPAN>fill<SPAN class="punctuation token">:</SPAN> bikingImage source<SPAN class="punctuation token">:</SPAN> bikingImage <SPAN class="punctuation token">}</SPAN> Image <SPAN class="punctuation token">{</SPAN> id<SPAN class="punctuation token">:</SPAN> disallowImage anchors<SPAN class="punctuation token">.</SPAN>fill<SPAN class="punctuation token">:</SPAN> parent source<SPAN class="punctuation token">:</SPAN> disallowSvg sourceSize<SPAN class="punctuation token">:</SPAN> Qt<SPAN class="punctuation token">.</SPAN><SPAN class="token function">size</SPAN><SPAN class="punctuation token">(</SPAN> width<SPAN class="punctuation token">,</SPAN> height <SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">}</SPAN> ColorOverlay <SPAN class="punctuation token">{</SPAN> color<SPAN class="punctuation token">:</SPAN> <SPAN class="string token">"red"</SPAN> anchors<SPAN class="punctuation token">.</SPAN>fill<SPAN class="punctuation token">:</SPAN> disallowImage source<SPAN class="punctuation token">:</SPAN> disallowImage <SPAN class="punctuation token">}</SPAN> <SPAN class="punctuation token">}</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
Les membres connectés peuvent publier, suivre les mises à jour, et plus encore. Nouveau ici ? Inscrivez-vous gratuitement.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.