Position Tooltip based on pointer position #967
-
|
Is there a way to position the tooltip relative to the pointer position rather than the content element position? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
I'm not sure what you're trying to achieve since you weren't super specific, but here's an example using the function App() {
const [position, setPosition] = React.useState({ x: 0, y: 0 });
return (
<div>
<button
data-tooltip-id="my-tooltip"
data-tooltip-content={`I'm placed at (x:${position.x}, y:${position.y})`}
onClick={(e) => {
setPosition({
x: e.clientX,
y: e.clientY,
});
}}
>
Click me
</button>
<Tooltip id="my-tooltip" events={['click']} position={position} />
</div>
);
}Using the |
Beta Was this translation helpful? Give feedback.
I'm not sure what you're trying to achieve since you weren't super specific, but here's an example using the
clickevent and watching for theonClickevent on the anchor.Using the
hoverevent and wat…