ghosh / microtip

💬 Minimal, accessible, ultra lightweight css tooltip library. Just 1kb.
https://microtip.vercel.app/
MIT License
1.38k stars 74 forks source link

tooltip is not working for img tag #46

Open schel4ok opened 4 years ago

schel4ok commented 4 years ago

Doing like that you will not see tooltip on mouse hover.

<img src="/storage/img/arigato.png" alt="hey tooltip" data-microtip-position="bottom" aria-label="hey tooltip" role="tooltip">

It works only for link tags like that

<a href="" data-microtip-position="bottom" aria-label="hey tooltip" role="tooltip">
<img src="/storage/img/arigato.png" alt="hey tooltip" ></a>

But documentation says you can use it on any tag

brunormferreira commented 3 years ago

Hi! I was with the same error, and I tried to encapsulate the element that you want to show a tooltip with a div element with the properties that need like that:

React component:

import React from 'react';

export function Tooltip({ position, label, children, ...props }) {
  return (
    <div
      data-microtip-position={position}
      aria-label={label}
      role="tooltip"
      {...props}
    >
      {children}
    </div>
  );
}

Thanks!