godot-ui-control
Godot 4.7 Control-node API for menus and HUDs: anchors, Containers, Theme and StyleBox, focus neighbours and stretch settings, with a headless layout check. Use when Godot UI overlaps or drifts on resize, buttons ignore the gamepad, or an invisible panel swallows clicks. Not for engine-neutral UI rules (`game-ui-ux`; load both) or rebinding (`input-systems`).
Install
npx skills add https://github.com/gamedev-skills/awesome-gamedev-agent-skills --skill godot-ui-controlGodot UI / Control nodes (4.x)
Lay out responsive UI with Control anchors and Container nodes, style it with a
Theme, make it navigable by keyboard and gamepad, and prove the layout holds at more
than one screen size. Targets Godot 4.7 (see Version notes). Design rules (what a good
HUD or menu needs) live in game-ui-ux; load both for engine UI work.
When to use
- HUDs, menus, inventories, dialog boxes or settings screens built from
Controlnodes; UI that must adapt to window size; theming; focus navigation for controller/keyboard.
When not to use: in-world Node2D/sprites → godot-nodes-scenes; UI tweens →
godot-animation; rebinding → input-systems; card hands and VN text boxes →
card-game / visual-novel.
Core workflow
- Read the stretch settings first.
project.godot[display]holdswindow/size/viewport_width/viewport_height(base size, default 1152x648),window/stretch/mode(canvas_itemsis the usual choice for UI-heavy games) andwindow/stretch/aspect(expandlets UI use extra width or height). Layout bugs on other screens usually start here. - Use
Controlnodes for UI, notNode2D, and put HUDs under aCanvasLayerso the game camera does not move them. -
Anchor top-level panels; let Containers place their children. Outside containers, set anchors with presets (
set_anchors_and_offsets_preset()). Inside aVBoxContainer,HBoxContainer,GridContainerorMarginContainer, the container owns position and size; steer it withsize_flags_*. In a.tscn, a Full Rect panel reads:Keep whatever
layout_modeline Godot wrote; it records whether anchors or a parent container drive the node. - Style with one
Theme. Set a project-wide theme withgui/theme/custom="res://ui/theme.tres"inproject.godot, or assignthemeon the top Control; children inherit it. Use per-nodeadd_theme_*_overrideonly for exceptions. - Wire focus. Give the first button focus when a menu opens (
grab_focus()), keepfocus_mode = FOCUS_ALLon anything a gamepad must reach, and setfocus_neighbor_*only where the automatic geometry guess is wrong. - Connect signals (
pressed,toggled,text_submitted,value_changed). -
Check before you finish.
- Run the layout test (Pattern 4) headless:
godot --headless --path . --script res://tests/test_ui_layout.gdand read the exit code. It flags controls pushed off-screen and menus with nothing focused, at each size. - Run the
godot-nodes-scenesskill'sscripts/check_godot_project.py <project-dir>if you edited.tscn/.tresfiles (themes, StyleBoxes, fonts). - For a picture, on a machine with a GPU (not
--headless), capture frames and look at them:godot --path . --resolution 2560x1080 --write-movie $OUT/menu.png --quit-after 3 --scene res://ui/main_menu.tscnwrites numbered PNGs next to that path. Repeat at 1280x720. - With no Godot binary (
godot,godot4or$GODOT_BIN), ask the user to run these and paste the output or screenshots. Ask the user to try the menu with a gamepad and report any button that cannot be reached.
- Run the layout test (Pattern 4) headless:
Patterns
1. Full Rect from code (anchors and offsets)
2. A menu from containers, with initial focus
3. One child takes the leftover space
4. Headless layout test at several sizes
Children of a ScrollContainer are meant to extend past it; skip them (or check only the
container) when the menu scrolls.
Gotchas
- Mixing manual position with Containers. A container child cannot keep its own
position or anchors; the container overwrites them on every sort. To nudge, rotate or
scale one (a hover pop), set
offset_transform_enabled = trueand useoffset_transform_position/_rotation/_scale, which the container leaves alone. - Anchors vs offsets. Anchors are fractions of the parent; offsets are pixels from the anchored point. Positioning with anchors at 0 makes UI ignore window size.
- UI under a
Node2Ddoesn't theme, anchor or take focus correctly. Keep UI in aControlsubtree, under aCanvasLayerfor HUDs. - Gamepad does nothing → nothing has focus. Call
grab_focus()when the screen opens; plainControls default toFOCUS_NONE,FOCUS_CLICKis mouse-only, andgrab_focus()on aFOCUS_NONEcontrol only prints a warning. - Invisible full-rect panel swallows clicks → its
mouse_filterisSTOP. SetMOUSE_FILTER_IGNOREon decorative panels and HUD roots. - Looks right in the editor, cramped or off-screen on ultrawide or 4:3 → stretch
aspectiskeep(black bars) or the panel is anchored to a corner instead of the edge it should follow. Test the sizes the UI actually gets (Pattern 4). - Theme vs override. Per-node
add_theme_*_overridecalls beat the inheritedTheme; many of them defeat central theming and make restyling slow. rect_*properties are renamed. Godot 3'srect_size/rect_position/rect_min_sizeare nowsize/position/custom_minimum_size.
References
- Read
references/layout-and-theming.mdwhen you need the anchor/offset maths, every Container type, size-flag values, building a Theme and StyleBox in code, focus neighbour wiring, offset transforms, the built-inVirtualJoystick, or common Control signals.
Related skills
game-ui-uxfor engine-neutral rules: scaling, safe areas, focus flow, screen stack.godot-animationfor Tween-based UI transitions.godot-signals-groupsfor wiring UI events to game logic.input-systemsfor rebindable input and multi-device focus.card-game/visual-novelfor UI-heavy genre templates.
Version notes
Last verified: 2026-11-11 against Godot 4.7.2-stable (released 2026-08-18).
Control.offset_transform_*and theVirtualJoysticknode are new in 4.7.- Default base size is 1152x648 and default stretch mode is
disabled, aspectkeep. --write-moviewith a.pngpath writes an image sequence;--resolutionrequests the window size.
Sources: Control @ 4.7.2-stable, ProjectSettings @ 4.7.2-stable, main.cpp @ 4.7.2-stable, Multiple resolutions, Godot 4.7 release.