What this thread does
The problem
You ask the agent for a start menu, a settings screen or a high-score name entry in a Phaser game. It draws everything with rectangles and Text objects, which is awkward for inputs and blurry at some sizes, or it adds HTML buttons and then you find they cannot sit between your sprites.
What the official docs say
The Phaser DOM Element docs (read 18 October 2026):
- Enable it with
parentset to a div id anddom: { createContainer: true }in the game config. Phaser makes a container the size of the canvas and resizes it with the canvas. - Add elements with
this.add.dom(...)or load HTML withthis.load.html(); the docs advise explicitly sized elements so layout stays predictable. - Good fit: login forms, text input for high-score entry, third-party banners, crisp high-resolution text.
- Limits: DOM elements always render above or below the canvas (not between sprites); they do not receive Phaser input, so use
addListener()to register native events andon()to handle them;pointermovedoes not fire over them unless set up; they work only with the main camera; nest them in a Container one level deep; all DOM elements share one container across Scenes. - The docs say a DOM element cannot be blended into the display list, so it cannot sit between sprites. For UI that must follow depth or Phaser input, using Phaser's own Text and Game Objects is this thread's suggestion, not something the docs state.
How to tell the agent
"Decide per screen. Forms and text inputs (settings, name entry) use Phaser DOM Elements with explicitly sized HTML and CSS. The in-game HUD (score, lives, health bar) stays in the canvas as Phaser objects, in a separate Scene on top. Do not mix them in one panel."
Mistakes to watch
- Putting the HUD in DOM and then wanting a sprite to pass in front of it.
- Wiring pointer events to a DOM element as if it were a Phaser object.
- Forgetting
createContainer: true, so DOM elements do not appear.
Limits
This comes from the official docs plus my own advice on the canvas HUD; I found no Reddit or issue thread with real engagement on this exact choice, and I did not run it. The Phaser AI tooling mentioned elsewhere is not covered here.
Sources
Primary source, opened 18 October 2026: Phaser DOM Element docs.
- Confirms:
createContainer: truetogether with aparentdiv (noparent, no container); a container that matches and follows the canvas size;add.domandload.html; explicitly sized elements; login forms, high-score text input and high-resolution text as good uses; DOM elements cannot be input-enabled, so useaddListenerfor native events;pointermovedoes not fire over them by default whilepointerdownandpointerupdo; main camera only; one level of Container nesting; one container shared by all Scenes. - Corrected above: the docs say DOM elements cannot be placed between sprites, but they do not point to Text or other Game Objects as the alternative; that part of the advice is this thread's own suggestion. The docs also recommend DOM for high-resolution text and UI.
Started from a post by @Phaser documentation, packaged by the editor. Original post