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-controlControl layout & theming reference (Godot 4.7)
Depth companion to godot-ui-control.
Contents: anchors and offsets · container types · size flags · Theme and StyleBox · focus navigation · offset transforms (4.7+) · touch joystick (4.7+) · HUDs over the game · common signals
Anchors and offsets
A Control has four anchors (anchor_left/top/right/bottom), each a fraction 0.0–1.0
of the parent's rect, and four offsets (offset_left/top/right/bottom) in pixels from the
anchored point.
- Anchors at
(0,0,0,0)→ the control's edges all track the parent's top-left; size is driven entirely by offsets (fixed pixel size, top-left aligned). - Anchors at
(0,0,1,1)(Full Rect) → edges track each corner; the control resizes with the parent. Offsets become margins. - Center presets set anchors to
0.5and use offsets relative to the center.
Use the editor's Layout toolbar, or in code
set_anchors_and_offsets_preset(Control.PRESET_*) (CENTER, FULL_RECT, TOP_WIDE,
BOTTOM_RIGHT, ...), which sets anchors and offsets together. Assigning anchor_* or
anchors_preset alone keeps the existing offsets, so the rect does not snap to the preset.
Container types
Containers ignore child anchors/positions and instead use size flags.
Size flags
Theme and StyleBox
A Theme resource maps (control type, property name) → value. Property kinds: color,
constant, font, font_size, icon, stylebox.
Per-node overrides (win over the inherited Theme):
StyleBoxFlat (solid color, borders, corners, shadows), StyleBoxTexture (9-patch
texture), and StyleBoxEmpty cover most needs.
Focus navigation (keyboard / gamepad)
The default UI input actions (ui_up/down/left/right/accept/cancel/focus_next) drive
focus movement; they map to arrow keys, Enter, and the gamepad D-pad/face buttons out of
the box.
Offset transforms (4.7+)
Containers overwrite their children's position, rotation and scale on every re-sort.
For animation inside a container, enable offset_transform_enabled and tween
offset_transform_position / _rotation / _scale (pivot: offset_transform_pivot_ratio,
centre by default). With offset_transform_visual_only = true (default) input still hits
the untransformed rect.
Touch joystick (4.7+)
VirtualJoystick is a built-in Control for touchscreens. Set joystick_mode
(JOYSTICK_FIXED, JOYSTICK_DYNAMIC, JOYSTICK_FOLLOWING) and the action_left/right/up/down
input actions it presses, then read movement with Input.get_vector() as for a gamepad.
HUDs over the game
Put HUD UI under a CanvasLayer so it renders on top of and independent from the moving
game camera. A Control set to Full Rect inside the CanvasLayer fills the viewport
regardless of world scrolling.
Common signals
Button.pressed,Button.toggled(toggled_on),Button.button_down/up.LineEdit.text_submitted(text),text_changed(text).Slider/SpinBox.value_changed(value).ItemList.item_selected(index),OptionButton.item_selected(index).Control.gui_input(event)for custom click/drag handling.