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.
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
- Terms with a
title, and onedrawabletooltip element. - Take the titles and choose the active term from pointer, tap and focus.
- Draw the term larger at its drawn place, then the tooltip.
- Styles.
Modal that leaves the scene
Tick some messages and press Delete selected. The confirmation is a <dialog> opened with showModal(), painted by the page. Behind it the canvas draws the inbox smaller, darker, blurred and grey. Cancel, Escape or a tap outside the dialog brings it back.
The dialog keeps what the browser gives a modal: focus is held inside it, the rest of the page is inert, and Escape closes it. The canvas only reads dialog.open.
Show the code
- The scene is a
drawablechild of the canvas. - The dialog is outside the canvas.
- Draw the scene from
dialog.open. - 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
- Add each toast as a
drawabledialog and draw the stack. - 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:
- Replace it. The tooltip is an ordinary element with
role="tooltip", drawn by the canvas where the term was drawn.getClientRects()of an inline element returns its drawn boxes, also when the draw was rotated. - Draw the other half. The modal dialog stays in the top layer. The canvas draws what is behind it.
- Keep it out of the top layer. A dialog with the
openattribute isn't in the top layer. It needsposition: staticto be laid out inside the canvas.
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
- The paint loop and the draw helpers shared by the three demos.
- Each demo starts when its section comes near the screen.
- A lost context stops every demo.
- 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.
- A canvas can draw its own tooltip at the drawn place of a term.
getClientRects()of an inline element inside a rotated draw returned a box whose middle was 0.1 px from where the rotation puts it. The box is the bounding box of the rotated text: 42.4 by 29.5 px for a 39 by 19 px span. - The drawn tooltip opens by mouse, by tap and by keyboard focus.
pointerover,clickandfocusinreach the terms where they are drawn. The page moves eachtitletodata-tip, so the browser's own tooltip doesn't appear as well, and points the term at the tooltip element witharia-describedby. - An open popover isn't in the picture of the element that holds it. None of 50 sampled pixels of the drawn box had the popover's colour. The same holds for a modal dialog (measured on /elements/).
- While a dialog is modal, the scene in the canvas is still drawn and can't be hit.
elementFromPoint()at the drawn scene returned the dialog. Withclosedby="any"a tap on the drawn scene closed the dialog. After it closed, a checkbox in the scene took a tap again. - The canvas can stand in for
::backdropfor its own scene. It draws the scene at 84% size throughblur(),saturate()andbrightness()filters fromdialog.open, and thetoggleandcloseevents of the dialog ask for the paint. A filter on a draw doesn't change where the element is found. - A
<dialog open>is drawn as adrawablechild if it isposition: static. Its buttons are found where it is drawn, also while it slides. A dialog added while the page runs is drawn from the next paint. - Not verified: everything on a phone. In particular a long press on a term (Android may show its own menu), the on-screen keyboard over the toast form, and where Android centres the modal dialog while the keyboard is open. A screen reader on the tooltip and on the toasts wasn't tried.