Developer forum

Forum » Swift » Creating new svg icons

Creating new svg icons

Timo Kofod
Reply
Is there a guide on how to create new (custom) .svg icons for Swift? Just like the ones allready in DW/Swift, that automatilly adapts the line color from the theme. Our design partner tried to make som new ones, but we can't get them to adabt the line color. I have tried to search the forum without any luck.

Replies

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Hi Timo

We have no such guide. But it has to do with the color set inside the svg file - you have to set the stroke attribute to currentColor - see https://stackoverflow.design/product/base/current-color/

<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" 
  fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" 
  stroke-linejoin="round" class="feather feather-gift">
 <polyline points="20 12 20 22 4 22 4 12"></polyline>
 <rect x="2" y="7" width="20" height="5"></rect>
 <line x1="12" y1="22" x2="12" y2="7"></line>
 <path d="M12 7H7.5a2.5 2.5 0 0 1 0-5C11 2 12 7 12 7z"></path>
 <path d="M12 7h4.5a2.5 2.5 0 0 0 0-5C13 2 12 7 12 7z"></path>
</svg>

Also there can be other attribnutes in SVGs created in other tools - some attributes might need to be removed.

 
Timo Kofod
Reply

Great. Thanks, Nicolai ðŸ˜Š

 

You must be logged in to post in the forum