DOM elements inside egui and Qt Quick apps

egui (Rust) and Qt Quick (C++) are native UI toolkits. Compiled to WebAssembly they draw every widget themselves into one WebGL canvas, so the page has no real inputs. Here both apps contain real <input>, <select> and <textarea> elements. The toolkit lays them out and draws them from a texture filled by texElementSubImage2D(). The browser handles their input.

egui

By signing up you agree to the terms. This sentence is DOM text: مرحبا, 你好, 👋🏽.

Loading the egui app (3.3 MB of WebAssembly)…

Rows marked DOM are real elements: the mobile keyboard, autofill, the native date and select pickers, the caret and text selection are the browser's. Rows marked egui are drawn by egui. Drag the egui window over the form, or use its sliders to change how the DOM fields are drawn.

Show the code a DOM element as an egui widget
  1. Put the elements inside the canvas that egui renders into. Each one has a name in data-egui.
  2. Style them like any other element. Their layout position isn't used.
  3. Start the app on that canvas.
  4. Rust: use a DOM element like a widget. self.dom.show(ui, "email", width, look) sits between egui's own TextEdit and Slider.
  5. Rust: the widget. Ask the browser for the height, allocate that space in egui, report the final position to the browser, and add a paint callback.
  6. Rust: the paint callback. It runs inside egui's WebGL pass, uploads the element if the browser repainted it, and draws one quad.
  7. JavaScript: element to texture. texElementSubImage2D() writes into the texture Rust has bound.
  8. JavaScript: tell the browser where egui drew it. updateElementGeometry() moves the element's hit box, caret and accessibility bounds there.
  9. JavaScript: keep egui and the element from both handling one event, and ask egui whether one of its windows is on top before an event reaches an element.
  10. All of lib.rs.
  11. All of bridge.js.

Qt Quick

Qt 6.10 for WebAssembly, with Qt Quick Controls. It isn't loaded until you ask.

The email, plan and notes fields are DOM elements shown by a DomItem in the QML scene. The sliders are Qt Quick Controls that set the items' opacity and rotation, and the rotated field still takes clicks and typing where it is drawn.

Show the code a DOM element as a Qt Quick item
  1. The elements. Qt's canvas is inside a shadow root, so page stylesheets don't reach it. The page copies each element's computed style inline before Qt takes it.
  2. QML: DomItem next to Qt Quick Controls. Layouts, opacity and rotation apply to it like any item.
  3. C++ with inline JavaScript: move the element into Qt's canvas. GLctx is Emscripten's WebGL context, the one Qt Quick draws with.
  4. C++: a GL texture that the scene graph draws. The upload runs on beforeRendering; QSGOpenGLTexture::fromNative() hands the texture to a QSGSimpleTextureNode.
  5. The upload call.
  6. Tell the browser where the item is. itemTransform() gives the item's matrix in the window, rotation included.
  7. All of domitem.cpp.

Live checks

The checks load a second copy of the egui app in a small frame, so they don't touch the one above. The Qt app was tested the same way with Playwright before it was published (see Findings).

ResultExperimentDetail

Findings

Other frameworks

How Qt, Flutter, Compose Multiplatform, egui, Dear ImGui, Slint, Avalonia, Uno Platform, Unity and Godot render on the web today, what each does about text input, accessibility and embedded HTML, and what HTML-in-canvas would change for each, with sources: docs/native-frameworks.md.

FrameworkDraws intoText input todayAccessibility todayHTML content today
Qt for WebAssemblyOne canvas per window. WebGL for Qt Quick, 2D putImageData for raster windows.A hidden <input> per window.A parallel tree of hidden ARIA elements, off by default.Not documented.
Flutter webWebGL canvas (CanvasKit or Skwasm).A transparent <input> or <textarea> placed over the field.A parallel flt-semantics tree, off until asked for.Platform views: elements slotted between extra canvases.
Compose MultiplatformCanvas (Skia).Open issues are on the roadmap.Initial support in 1.9.WebElementView: an element laid over the canvas.
eguiWebGL or WebGPU canvas.A hidden <input> ("text agent").None on the web apart from an experimental speech output.None.
SlintWebGL canvas.No IME with the Emscripten backend.Not available.None.
AvaloniaWebGL canvas (Skia through CanvasKit).Not stated.Partial, through ARIA attributes.JavaScript interop only.
Uno Platform (Skia)WebGL canvas.IME is work in progress.Work in progress.Native element hosting, no alpha blending.
Unity, GodotWebGL canvas.A real text field is needed to raise a mobile keyboard.None documented for the web.Page elements over the canvas, by hand.

Each cell is sourced in the document. "Not stated" and "not documented" mean the framework's own pages didn't say.