Tippyjs: disabled buttons prevent the tooltip from showing

Created on 2 Sep 2018  路  5Comments  路  Source: atomiks/tippyjs

When I set a button element to disabled, it's tippy never displays on click or hover event. Is there a workaround for this?

Most helpful comment

Yes: use a wrapper element that isn't disabled and apply the tooltip to that.

<div title="tooltip" tabindex="0">
  <button disabled>btn</button>
</div>
tippy('div')

All 5 comments

Yes: use a wrapper element that isn't disabled and apply the tooltip to that.

<div title="tooltip" tabindex="0">
  <button disabled>btn</button>
</div>
tippy('div')

sorry forgot to close this ticket. Definitely a good workaround, thanks!

I'm having problems that the tooltip has a lot of margin to the input element if a wrapping div is used for showing tooltips on disabled elements.

Simle example: https://jsfiddle.net/xpvt214o/929062/

Could be worked around by setting the width for both elements so that the container is the leading element for the target with, and our input get width: 100%. But I would prefer a more clean solution. It would be the best if we got a fix from tippyjs so that tooltips can be shown for disabled elements.

Also having this explicity enabled via config is fine, because some users may don't want show tooltips for disabled elements. But in my case it's a problem since I want to use tooltips for notifying the user how he can request changes to readonly fields.

Well a div is a block element, if you are wrapping an input use a span element instead

@atomiks My fault, I was in a hurry and didn't think about it. Now it works as expected 馃憤
Maybe this workaround should be added in the documentation, when others may have the requirement of tooltips in disabled elements, too.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gclark18 picture gclark18  路  4Comments

dpatra picture dpatra  路  4Comments

divmgl picture divmgl  路  3Comments

khanamiryan picture khanamiryan  路  5Comments

Kearsan picture Kearsan  路  3Comments