2

Is there any default method to hide tooltip after a few seconds on click? I want to show it on click for 2 sec and then close it. how should i do this?

user2177459
  • 97
  • 3
  • 9

1 Answers1

11

You need to set a timeout when the tooltip is first shown. I also like to add hideOnClick: false so that it doesn't disappear when they click somewhere else.

Here's a complete example for you:

tippy('#button', {
  trigger: 'click',
  hideOnClick: false,
  onShow(instance) {
    setTimeout(() => {
      instance.hide();
    }, 2000);
  }
});
NuclearApe
  • 573
  • 2
  • 6
  • 16