Godot ui theming

From thedivergentai/GD-Agentic-Skills · View interactive version

Godot ui theming is an AI agent skill from the GitHub repository thedivergentai/GD-Agentic-Skills. Expert blueprint for UI themes using Theme resources, StyleBoxes, custom fonts, and theme overrides for consistent visual styling. Covers StyleBoxFlat/Texture, theme inheritance, dynamic theme switching, and font variations. Use when implementing consistent UI styling OR supporting multiple themes.

How to use this skill

Skill file

UI Theming

Theme resources, StyleBox styling, font management, and override system define consistent UI visual identity.

Available Scripts

[global_theme_manager.gd](scripts/global_theme_manager.gd)

Expert theme manager with dynamic switching, theme variants, and fallback handling.

[ui_scale_manager.gd](scripts/ui_scale_manager.gd)

Runtime theme switching and DPI/Resolution scale management.

[theme_swapper.gd](scripts/theme_swapper.gd)

Dynamic Dark/Light mode implementation using cascading theme root propagation.

[danger_button_assignment.gd](scripts/danger_button_assignment.gd)

Expert use of theme_type_variation for semantic UI styling without scene duplication.

[dynamic_stylebox_color.gd](scripts/dynamic_stylebox_color.gd)

Safe runtime StyleBox modification. Demonstrates the critical duplicate() pattern for isolated overrides.

[procedural_theme_safe.gd](scripts/procedural_theme_safe.gd)

Reliable theming for generated UI elements using NOTIFICATION_THEME_CHANGED.

[custom_chart_drawing.gd](scripts/custom_chart_drawing.gd)

Pattern for reading active Theme properties (colors, fonts) in custom _draw() logic.

[theme_isolation.gd](scripts/theme_isolation.gd)

Ensuring HUD consistency by isolating nodes from parent themes and referencing Project Defaults.

[pulsating_ui_theme.gd](scripts/pulsating_ui_theme.gd)

Animating UI styles via Tweens. Targets StyleBox properties directly after duplication.

[crisp_ui_scaler.gd](scripts/crisp_ui_scaler.gd)

High-quality resolution-independent scaling using content_scale_factor to maintain font crispness.

[memory_safe_custom_drawing.gd](scripts/memory_safe_custom_drawing.gd)

Fixing the "disappearing stylebox" bug by caching resources at the class level for the RenderingServer.

[rtl_theme_mirroring.gd](scripts/rtl_theme_mirroring.gd)

Bi-directional (RTL/LTR) UI support. Swaps theme variants dynamically based on layout direction.

[focus_prompt_icon_swapper.gd](scripts/focus_prompt_icon_swapper.gd)

Controller/keyboard prompt icon bank swap + focus highlight panel. MANDATORY for accessibility prompt chrome.

NEVER Do in UI Theming

Decision Tree — Theme Ownership

| Goal | Choose | Notes / script |

|------|--------|----------------|

| App-wide look | Project Settings → GUI → Theme | Author in Theme editor — no per-node StyleBox tutorials here |

| One Control differs | add_theme_*_override on that node | Local only; never for global styles |

| Button/panel subtype | theme_type_variation | See danger_button_assignment.gd |

| Runtime color tweak without mutating shared Theme | stylebox.duplicate() then override | See dynamic_stylebox_color.gd |

Fonts & StyleBoxes: edit via Theme editor / Project Theme. Runtime helpers: global_theme_manager.gd, theme_swapper.gd, procedural_theme_safe.gd.

Expert Theming Patterns

1. Shared-Color-Palette (The Static Pattern)

Maintain a single source of truth for UI colors accessible to both the Theme Editor and GDScript.

2. Theme-Type-Variations

Avoid duplicating button scenes or styleboxes for variants like "Danger" or "Ghost" styles.

MANDATORY: Read danger_button_assignment.gd — do not fork Button scenes for color variants.

3. Runtime StyleBox Color (duplicate first)

When a single Control needs a runtime tint, duplicate the StyleBox before mutating — shared Theme StyleBoxes must stay immutable.

MANDATORY: Read dynamic_stylebox_color.gd — never mutate a Theme StyleBox in place.

4. Runtime-Theme-Swapping (Accessibility)

Efficiently switch the visual style of the entire game for Light, Dark, or High-Contrast modes.

MANDATORY: Read theme_swapper.gd — swap at the theme root; do not walk every Control assigning themes.

5. RTL / LTR Theme Mirroring

Bi-directional layouts need mirrored StyleBox / type-variation banks when direction flips — not hand-flipped anchors alone.

MANDATORY: Read rtl_theme_mirroring.gd — swap theme variants from layout direction; do not hardcode LTR margins.

6. Themed-Asset-Loading (Seasonal Variants)

Godot Themes support more than just colors and fonts—they can store textures.

7. UI-Focus-Manager (Dynamic Controller Icons)

Standard focus styles are static. For accessibility UX, swap prompt icons by device and tween a highlight panel to get_global_rect().

MANDATORY: Read focus_prompt_icon_swapper.gd — do not paste joypad icon paths into Control scripts.

Pairs with Runtime-Theme-Swapping (Accessibility) above and theme_swapper.gd for High-Contrast roots.

8. Asset-Dependency-Audit (Draw-Call Reduction)

Ensuring UI textures are optimized for rendering performance.

Deep recipes (on demand)

LLM-ignorance rule: if a general agent would not know it before reading, it lives here or in scripts/ — never delete, only move.

| Topic | Reference |

|-------|-----------|

| StyleBox / font setup | theme-authoring-recipes.md |

Reference

Progressive disclosure: open Official Documentation links only when researching a specific API;

load Related Skills when routing work to a peer domain — do not preload the whole lattice.

Official Documentation

Related Skills

Prerequisites
Complements
Downstream / consumers
Master
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.