Custom Position Tooltip Without React Child Doesn't work
See original GitHub issueHi!
Problem: (Disclaimer: This issue is probably my mistake) but I’ve been using Popper previously for modals and was thinking of having Popper’s Usage without a reference HTMLElement with Tippy that I came across Custom position section of the Tippy docs and I tried it with Tippy.js-React like this:
<Tippy
      content="Hello"
      onCreate={instance => {
        if (instance.popperInstance) {
          instance.popperInstance!.reference = {
            clientHeight: dimensions.height,
            clientWidth: dimensions.width,
            getBoundingClientRect: () => {
              return {
                left: rect.left,
                right: rect.right,
                top: rect.top,
                bottom: rect.bottom,
                height: rect.height,
                width: rect.width
              };
            }
          };
        }
      }}
    >
      <button>Hello</button>
    </Tippy>
It shows up but it is not in its position and it already has a child which is the <button></button>, probably I was expecting something like this:
    <Tippy
      content="Hello"
      onCreate={instance => {
        if (instance.popperInstance) {
          instance.popperInstance!.reference = {
            clientHeight: dimensions.height,
            clientWidth: dimensions.width,
            getBoundingClientRect: () => {
              return {
                left: rect.left,
                right: rect.right,
                top: rect.top,
                bottom: rect.bottom,
                height: rect.height,
                width: rect.width
              };
            }
          };
        }
      }}
    />
But Both Typescript and React don’t like it because they both expect the child in the TIppy Element.
Ways to reproduce: Mentioned in the problem section.
Issue Is there any way I can have Tippy without a React child and be positioned with costum position?
Thanks a lot in advance.
Edit: A word.
Issue Analytics
- State:
 - Created 4 years ago
 - Comments:6 (2 by maintainers)
 
Top Results From Across the Web
Custom Position Tooltip Without React Child Doesn't work #173
Hi! Problem: (Disclaimer: This issue is probably my mistake) but I've been using Popper previously for modals and was thinking of having ...
Read more >Material UI tooltip doesn't display on custom component ...
Your Tooltip is not working properly because the child of a Material-UI Tooltip must be able to hold a ref. The following can...
Read more >How To Make an Extremely Reusable Tooltip Component ...
Make it go above anything you want to show a tooltip on hover. It takes three props: content , which will be what's...
Read more >Building a simple tooltip component that never goes off screen
How to build a simple, responsive and lightweight tooltip web component, with minimal HTML, CSS and JavaScript and no framework dependency.
Read more >React Tooltip component - Material UI - MUI
Custom child element The tooltip needs to apply DOM event listeners to its child element. If the child is a custom React element,...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

This should work fine in
@tippyjs/reactv4.0.0-alpha.1 (no dot, it’s a new package entirely), since it doesn’t require a child and you can use thegetReferenceClientRectprop 😃Ah, sorry, found
getReferenceClientRectnow. This works great!