I can't change the notification icons

AI-generated summary

I can’t change the notification icons

User Mikhail_Tyuftyaev is having trouble changing the notification icons. They’ve tried modifying the Header but it’s not working. Don suggests using a script to replace the icon, providing an example:

<script type="text/discourse-plugin" version="0.8">
  api.replaceIcon('notification.granted_badge', 'oo-medal-badges');
</script>

Mikhail_Tyuftyaev confirms that this solution works.

To identify the icon name, Don recommends using Inspect Elements. Mikhail_Tyuftyaev asks where to find the icon list, and Don points to the icon-library.js file on GitHub.

kjs-fgx shares their experience with replacing icons, noting that the same icon can be referred to in different ways. They provide an example of how to replace the envelope icon in the header.html file:

    api.replaceIcon('envelope', 'fgx-air-mail');
    api.replaceIcon('far-envelope', 'fgx-air-mail');
    api.replaceIcon('notification.private_message', 'fgx-air-mail');
    api.replaceIcon('notification.read_private_message', 'fgx-air-mail');
    api.replaceIcon('notification.invited_to_private_message', 'fgx-air-mail');

The app/styleguide/atoms/icons list can be used to find the correct icon references.

Hi, everybody
I want to change these icons

I did it like this

And I wrote it in the Header

But the icon has not changed
It works with other icons
Please help me solve this problem

Hi Mikhail,

Please try this one :slightly_smiling_face:

<script type="text/discourse-plugin" version="0.8">
  api.replaceIcon('notification.granted_badge', 'oo-medal-badges');
</script>

You can find these replacements here :arrow_down:

Yes, it worked. Thank you very much

And where can I see what they look like?

You can easily identify it by using inspect elements.

For example.: the certificate icon notification

  1. Find the icon name with inspect elements


  1. Find the same icon in the icon-library js

Then you can replace the icon with any other icon you want. :slightly_smiling_face:

Thanks for your reply
I figured it out. I thought there was some sort of list with standard Discourse icons

May I add this for future reference. I followed the instructions on Replace Discourse's default SVG icons with custom icons in a theme - #19 but but what I did not realise at first was that the same icon can be referred to in different ways. In the app itself, under ‘/styleguide/atoms/icons’ is a list of all the icons and how they are referred to, so in my header.html file I now have 5 references to the envelope icon:

    api.replaceIcon('envelope', 'fgx-air-mail');
    api.replaceIcon('far-envelope', 'fgx-air-mail');
    api.replaceIcon('notification.private_message', 'fgx-air-mail');
    api.replaceIcon('notification.read_private_message', 'fgx-air-mail');
    api.replaceIcon('notification.invited_to_private_message', 'fgx-air-mail');