Oh, interesting, it looks like it's using dom-to-image under the hood, which doesn't actually take a screenshot of what you see -- instead it copies a DOM node and renders it to an off-screen canvas object.
I don't believe there's a straightforward way to insert arbitrary HTML into an htmlwidget. When the htmlwidget starts out, it is simply an empty div with some classes, including "leaflet"
and "html-widget"
. The initialization of the htmlwidget is what adds all the stuff inside.
This post asks the exact same question: How can we pass (compile-time R-generated) HTML to an htmlwidget?
One kind of hacky thing you could do is to add a bit of JavaScript code that will find the absolute panel (perhaps using the class or ID) and move it into the leaflet div. You will need to make sure this happens after the htmlwidget is initialized, though.