A tooltip, a modal and toasts beside the top layer

Three ideas from the element catalogue. A native tooltip, a modal dialog and a popover are painted by the page in the top layer, upright and outside any canvas, so a canvas can't draw them. Each demo takes one of them and does the part a canvas can do: it draws its own tooltip from the title text, it draws the scene behind a modal dialog moving away, and it draws toasts that are dialogs kept out of the top layer.

Tooltip drawn by the canvas

The underlined terms have a title. Point at one with a mouse, tap it, or press Tab to reach it. The canvas draws the term larger and marked, and draws the tooltip beside it. The card is drawn tilted, so the place of each term comes from where the canvas drew it.

Shipping forecast

Wind SW 5 to 7, veering NW later. Sea state rough. Visibility good, pressure 1004 hPa and falling.

No tooltip. Point at, tap or tab to an underlined term.

The browser's own tooltip for a title is painted outside the canvas, appears only for a mouse and can't be styled. The tooltip here is a role="tooltip" element that the canvas draws, and it also opens by touch and by keyboard.

Show the code
  1. Terms with a title, and one drawable tooltip element.
  2. Take the titles and choose the active term from pointer, tap and focus.
  3. Draw the term larger at its drawn place, then the tooltip.
  4. Styles.

Toast stack in the scene

Press Save a few times. Each toast is a non-modal <dialog open> that the canvas draws sliding in and stacking. Undo and the cross on a toast are real buttons.

    A dialog opened with the open attribute or show() stays in normal layout, so it can be a drawable child and the canvas can animate it. Opened with showModal(), or as a popover, it would be in the top layer and the canvas couldn't draw it.

    Show the code
    1. Add each toast as a drawable dialog and draw the stack.
    2. Styles. A toast is position: static.

    How it works

    An element's picture holds what the element paints in normal flow. The top layer is a separate list that the browser paints over the whole page: modal dialogs, popovers, and the picker of a customisable select. A native title tooltip is drawn by the browser's own interface, outside the page. None of these can be passed to drawElementImage(). The three demos work beside that limit in three ways:

    A fourth idea from the same list, a menu that opens flat from buttons drawn in perspective, is already built as /popovers/: there the popover stays in the top layer and CSS anchor positioning keeps it on the drawn button.

    Show the code
    1. The paint loop and the draw helpers shared by the three demos.
    2. Each demo starts when its section comes near the screen.
    3. A lost context stops every demo.
    4. The elements are then shown as plain HTML.

    Live checks

    The checks wait for a tap. Each one builds its own small canvas in a corner of the window, and none of them touches the demos above. No check opens a modal dialog, because that moves focus.

    Findings

    Measured in headless Chromium 157 on 2026-11-21, with a mouse, a keyboard and emulated touch. Not yet run on a phone.