I am developing an app and I need to add SLDS icon with custom color (i.e. green or blue) to the UI. Which is why I can't use <lightning-icon> component because you can override it style.

Thus I tried tu use a bare SLDS Svg with the folowing markup :

<span class="slds-icon_container slds-icon-utility-comments">
      <svg xmlns="http://www.w3.org/2000/svg" style="fill: #3496ec" class="slds-icon slds-icon-text-default" aria-hidden="true">
           <use xlink:href="/assets/icons/standard-sprite/svg/symbols.svg#comments"></use>

However the icon is not rendered and I have a 404 not found error in the console about the icon's link.

Any idea about that ?


Change "/assets" to "/_slds" in the use element.

<use xlink:href="/_slds/icons/standard-sprite/svg/symbols.svg#comments"></use>
  • I just tested and it doesn't work in my case
    – Ombrelin
    Feb 13 '20 at 15:23
  • 2
    I can confirm this works in Winter 2020. My example: <use xlink:href="/_slds/icons/utility-sprite/svg/symbols.svg#check"></use>
    – Mattisdada
    Jun 24 '20 at 5:22
  • This works with Edge
    – Cray Kao
    Jan 4 at 4:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.