How to make a cozy game UI theme in Godot 4
Pack for this guide: Crisp Cute (free sampler on itch.io). Also fits: Crisp Kit.
Short answer: Create one Theme resource and fill it with StyleBoxTexture styles: each points at a PNG and has texture margins (the 9-slice borders that never stretch) and content margins (the padding around the text). Set the normal, hover, pressed and disabled styles for Button, the panel style for PanelContainer, a soft rounded font and warm colours, then add theme type variations (such as a PanelCloud based on PanelContainer) for extra looks. Assign the theme to your root Control, or to the whole project in Project Settings.
1. Decide on the cozy look
- Rounded, chunky shapes with a thick outline in a darker tint of the fill colour (black outlines look harsh).
- A pastel palette, with warm dark text (a deep brown or berry instead of black) and at least 4.5:1 contrast for body text.
- A rounded font such as Fredoka, and generous padding.
- Small details (stitches, cloud bumps, hearts) kept inside the 9-slice borders, so they never stretch.
2. Get each piece's 9-slice numbers
Every stretchable piece needs two sets of four numbers. Texture margins mark the borders that are drawn at their own size. Content margins are the padding between the edge and the label. The Crisp Cute free sampler lists both in sheets.json:
sheets.json (one entry)
"name": "button_medium_normal", "size_1x": [144, 50],
"slice_1x": {"left": 26, "top": 20, "right": 26, "bottom": 23},
"content_padding_1x": {"left": 20, "top": 6, "right": 20, "bottom": 11}
You can drag any sampler piece to a new size and read its borders in the UI kit 9-slice preview.
3. Build the Theme
cozy_theme.gd
class_name CozyTheme
## Builds a cozy Theme from 9-slice PNGs. Values are the Crisp Cute sampler's sheets.json (1x).
const DIR := "res://ui/crisp_cute/"
const INK := Color("6d2f47") # body text
const OUTLINE := Color("783650") # button label outline
static func box(file: String, slice: Array, pad: Array) -> StyleBoxTexture:
var sb := StyleBoxTexture.new()
sb.texture = load(DIR + file)
sb.texture_margin_left = slice[0]
sb.texture_margin_top = slice[1]
sb.texture_margin_right = slice[2]
sb.texture_margin_bottom = slice[3]
sb.content_margin_left = pad[0]
sb.content_margin_top = pad[1]
sb.content_margin_right = pad[2]
sb.content_margin_bottom = pad[3]
return sb
static func build() -> Theme:
var t := Theme.new()
t.default_font = load("res://fonts/Fredoka.ttf")
t.default_font_size = 18
# Buttons: same slice in every state; pressed moves the label down 3 px.
var slice := [26, 20, 26, 23]
t.set_stylebox("normal", "Button", box("button_medium_normal.png", slice, [20, 6, 20, 11]))
t.set_stylebox("hover", "Button", box("button_medium_hover.png", slice, [20, 6, 20, 11]))
t.set_stylebox("pressed", "Button", box("button_medium_pressed.png", slice, [20, 9, 20, 8]))
t.set_stylebox("disabled", "Button", box("button_medium_disabled.png", slice, [20, 6, 20, 11]))
t.set_stylebox("focus", "Button", StyleBoxEmpty.new())
for c in ["font_color", "font_hover_color", "font_pressed_color", "font_focus_color"]:
t.set_color(c, "Button", Color.WHITE)
t.set_color("font_outline_color", "Button", OUTLINE)
t.set_constant("outline_size", "Button", 6)
# Panels: PanelContainer gets the plain panel, Label gets the ink colour.
t.set_stylebox("panel", "PanelContainer", box("panel.png", [24, 24, 24, 28], [16, 14, 16, 18]))
t.set_color("font_color", "Label", INK)
# Type variations: extra looks that inherit everything else from their base type.
t.set_type_variation(&"PanelInset", &"PanelContainer")
t.set_stylebox("panel", "PanelInset", box("panel_inset.png", [20, 20, 20, 20], [12, 12, 12, 10]))
t.set_type_variation(&"PanelCloud", &"PanelContainer")
var cloud := box("panel_cloud.png", [34, 32, 34, 26], [18, 30, 18, 18])
cloud.axis_stretch_horizontal = StyleBoxTexture.AXIS_STRETCH_MODE_TILE_FIT # the bumps repeat
t.set_stylebox("panel", "PanelCloud", cloud)
t.set_type_variation(&"LabelTitle", &"Label")
t.set_font_size("font_size", "LabelTitle", 28)
return t
The pressed style moves the label down 3 px (content margins 9 and 8 instead of 6 and 11) to match the art pressing in. An empty focus style hides Godot's default focus rectangle, which clashes with soft art; if players use a keyboard or gamepad, give focus a visible style instead, such as a soft ring piece.
To save the theme as a .tres you can edit in the inspector, run this once from the script editor (File > Run):
make_theme.gd
@tool
extends EditorScript
func _run() -> void:
ResourceSaver.save(CozyTheme.build(), "res://ui/cozy_theme.tres")
You can also build the same theme by hand: create a new Theme resource and use the Theme editor panel at the bottom of the screen.
4. Apply the theme
Set the theme property of the top Control of your UI scene: every control under it inherits the theme. To use it everywhere, set Project Settings > GUI > Theme > Custom to the .tres file.
5. Use theme type variations
A type variation is a named style set that inherits from a base type. Set a control's Theme Type Variation (theme_type_variation) to use it:
$ShopWindow.theme_type_variation = &"PanelCloud" # a PanelContainer with the cloud-top panel
$ShopTitle.theme_type_variation = &"LabelTitle" # a Label at 28 px, same colour
Anything the variation does not set comes from the base type, so LabelTitle keeps the ink colour of Label. The cloud panel's top bumps are drawn to repeat, so its horizontal axis tiles (AXIS_STRETCH_MODE_TILE_FIT) instead of stretching.
6. Keep it sharp at every size
- Do not make a 9-slice piece smaller than its texture margins added up, or the corners squash. The button above needs at least 43 px of height (20 + 23), but Godot sizes it from the font and content margins (40 px in our test), so give buttons a
custom_minimum_sizeof at least 50 px tall, the height of the art. - Use 2x art (and double every margin) for 1080p and phones, or set Display > Window > Stretch > Mode to
canvas_itemsto scale a 1x layout cleanly. - For pixel-art kits, set Rendering > Textures > Canvas Textures > Default Texture Filter to Nearest.
How this was tested
Run headless in Godot 4.7.2 with the Crisp Cute free sampler pieces and font: the theme was built and saved as a .tres, and a Button, a PanelContainer, a PanelCloud variation and a LabelTitle variation each picked up the right style, margins, size and colour.
Free assets to try
Crisp Cute Free: 54 images (34 Strawberry Milk theme pieces such as buttons, panels, a dialogue box, slots and bars, plus 20 colour icons) as PNG 1x and 2x and SVG, a sheets.json with every 9-slice border and padding, and the Fredoka font. The numbers in this guide come from it. Download Crisp Cute Free.
Crisp Kit Free: 57 flat, rounded pieces for casual games, also available as a ready-made Godot 4 Theme: crisp-kit-free-theme on GitHub or Crisp Kit Free on itch.io.
The full Crisp Cute ($6.99) has 130 pieces in each of 6 pastel themes and 138 cozy icons, with a ready-made Godot 4 Theme per colour theme (1x and 2x), Fredoka set up, type variations for the extra shapes and a demo scene. Claude (an AI assistant) designed everything in this pack: every shape is drawn by code. Crisp Kit ($6.99) is the casual-game counterpart with 8 colour themes. All 19 Crisp packs are also in the Crisp Everything Bundle for $17.99.