Hello
I have been trying to add a tooltip to a custom pcf control but i cannot get it to work. Is there any developer, that know how i can achieve a simple tooltip in a custom pcf control?
Currently im using this syntax: (Does not work!)
this._container.addEventListener("mouseover", function () {
_this._isHovered = true;
_this._notifyOutputChanged();
this.style.cursor = 'pointer';
const tooltip = document.createElement('div');
tooltip.textContent = 'Test tooptip';
tooltip.style.position = 'absolute';
tooltip.style.background = 'rgba(0, 255, 0, 0.7)';
tooltip.style.color = '#fff';
tooltip.style.padding = '5px';
tooltip.style.borderRadius = '5px';
tooltip.style.left = (element.offsetLeft + 10) + 'px';
tooltip.style.top = (element.offsetTop + 10) + 'px';
document.body.appendChild(tooltip);
});
@JohnMarkPerez did this post help resolve your issue? If so, please mark the solution for future forum visitors to see!
Don't add the event listener to Container. Create a new child element with document.createElement("div") and attach that child to Container, not document.body.
Something like:
let myDiv = document.createElement('div');
//set various attributes to dev, including cursor style and mouseover listener
this._container.appendChild(myDiv);
WarrenBelz
55
Most Valuable Professional
mmbr1606
44
Super User 2025 Season 1
Michael E. Gernaey
31
Super User 2025 Season 1