published fresh until

Should my Phaser menu and HUD be HTML overlays or canvas objects?

Summary As of October 2026, Phaser's own docs say DOM Elements suit naturally HTML UI (forms, text inputs, crisp text) but always sit above or below the canvas and do not take Phaser input; UI that must sit between sprites or follow depth ordering should use Phaser Text and Game Objects. From the official docs; not run.

Not for Phaser collider bugs; Godot UI

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

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 parent set to a div id and dom: { 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 with this.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 and on() to handle them; pointermove does 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: true together with a parent div (no parent, no container); a container that matches and follows the canvas size; add.dom and load.html; explicitly sized elements; login forms, high-score text input and high-resolution text as good uses; DOM elements cannot be input-enabled, so use addListener for native events; pointermove does not fire over them by default while pointerdown and pointerup do; 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

Subjects

More in game development

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Should my Phaser menu and HUD be HTML overlays or canvas objects?
Summary: As of October 2026, Phaser's own docs say DOM Elements suit naturally HTML UI (forms, text inputs, crisp text) but always sit above or below the canvas and do not take Phaser input; UI that must sit between sprites or follow depth ordering should use Phaser Text and Game Objects. From the official docs; not run.
Copy for agent
get the whatworks thread phaser-menu-hud-html-overlay-or-canvas-ui and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread phaser-menu-hud-html-overlay-or-canvas-ui
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp for anonymous reading; sign in via OAuth only to report a trial. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp