I have the following code below. What I want to do is to change the icons that appear, while retaining the same API (the icon: 'pi pi-check-circle', argument). In other words, I want zero edits to the code below and a different icon to appear on screen.
Is this possible? Please show me how to do it.
my.component.html
<p-toast position="top-left" class="p-toast-position"/>
my.component.ts
this.messageService.add({
severity: 'success',
detail: 'Message Content',
icon: 'pi pi-check-circle',
sticky: true,
});
I looked here for solutions but all involve customising my own components or inserting my own templates, but those are intrusive and adopting them means I need to more code just to use a different icon.
I found the answer to my question. This solution assumes you use icomoon.io and SVG icons.
icomoon.{woff|svg|ttf|eot}. You should also see ademo.htmlfile.Now you have the font ready.
In
pi-icon-name, replace<the respective unicode character>with the unicode you see ondemo.html. If the unicode ise900, enter\e900. Refer to the picture below for more info.styles.cssYou'll then be able to use the same API like below:
my.component.tsCaveat
If you want to extend instead of replace primeicons, use your own CSS class naming system. I.e. don't name it
.pi,.pi-*, because it clashes with primeicon's classes etcIcomoon alternatives