Search code examples
popupsvgtooltip

How to create an SVG "tooltip"-like box?


Given an existing valid SVG document, what's the best way to create "informational popups", so that when you hover or click on certain elements (let's say ) you popup a box with an arbitrary amount (i.e. not just a single line tooltip) of extra information?

This should display correctly at least in Firefox and be invisible if the image was rasterized to a bitmap format.


Solution

  • <svg>
      <text id="thingyouhoverover" x="50" y="35" font-size="14">Mouse over me!</text>
      <text id="thepopup" x="250" y="100" font-size="30" fill="black" visibility="hidden">Change me
        <set attributeName="visibility" from="hidden" to="visible" begin="thingyouhoverover.mouseover" end="thingyouhoverover.mouseout"/>
      </text>
    </svg>
    

    Further explanation can be found here.