shakee93 / vue-toasted

🖖 Responsive Touch Compatible Toast plugin for VueJS 2+
https://shakee93.github.io/vue-toasted/
MIT License
2.21k stars 194 forks source link

How to use icon in action text ? #134

Open eliyas5044 opened 5 years ago

eliyas5044 commented 5 years ago

Great work. Everything is fine for me. Just want to modify action text as Material Icon for closing toast.

action : {
        text : 'Close',
        onClick : (e, toastObject) => {
            toastObject.goAway(0);
        }
    }
cristiancalara commented 5 years ago

Hey @eliyas5044 - I was looking for the same thing. Looking at the source code, turns out you can use icon instead of text.

action: {
    icon: 'close',
    onClick: (e, toastObject) => {
        toastObject.goAway(0);
    }
}
ccleve commented 4 years ago

Setting icon: 'close' might work for a standard icon set, but I'm using Font Awesome Light. So I set the iconPack to "custom-class" and

  action: {
    icon: {
      name: "fal fa-times",
      after: true
    },
    onClick: (e, toastObject) => {
      toastObject.goAway(0);
    }
  }

This does not work. It does correctly put after the text, but it doesn't insert the classes.

My purpose is to put a simple X at the right edge so a user can close.

maxsimych commented 4 years ago

Is there any ideas now?) The same for me, I use svg icons and try to implement callback or custom-class in action icon, but it not works. Version 1.1.27

larbi-ceetiz commented 2 years ago

this one works:

  options: {
  iconPack:'custom-class'
        action: {
          icon: 'icon-cross',
          onClick: (_e, toastObject) => {
            toastObject.goAway(0)
          }
        }
        }