Styling

How game screens resolve colors, fonts and metrics through .theme themes, and how the editor's themes, density and motion settings apply to Miri widgets.

Last updated Dec 4, 2026Version 1.1.0

Miri has two styling layers. Game themes (.theme assets) let each game screen resolve color, font and metric tokens against its own palette. The editor style ("Mowo Graphite") is the editor's own palette, with Dark, Light and High Contrast themes; editor extensions draw with its tokens. This page covers both.

Game themes (.theme)

Game screens in MiriGraphics do not use the editor palette directly. A .ui screen resolves color tokens such as "accent" or "textbright" through an FMiriGraphicsTheme, stored as an MDF .theme asset Engine/Source/Gameplay/MiriGraphics/Api/MiriGraphics/FMiriGraphicsTheme.h.

Assets/UI/Game.theme
UITheme "Sample Game" {
    Colors {
        accent: vec4(0.20784314, 0.64705884, 0.8980392, 1.0)
        textbright: vec4(0.9098039, 0.91764706, 0.9254902, 1.0)
        scanner: vec4(0.32000002, 0.96, 0.72, 1.0)
    }
    Fonts {
        Font "body" {
            family: "Geist"
            size: 14.0
        }
    }
    Metrics {
        corner_radius: 4.0
    }
}

A Font entry may add raster: "msdf" (or "sdf") to draw text of that token as a distance field; the default is bitmap. Text and fonts covers the rasters.

This is an excerpt of the sample theme. A theme can add any token name, like scanner above, and screens can reference it.

Resolution order

  1. Screen's own theme:
  2. Project theme
  3. Built-in default theme
The first theme that defines the token wins.
  1. The theme: property at the root of the .ui.
  2. The host's project theme, set with CMiriGraphicsScreenStack::SetProjectTheme(path) Engine/Source/Gameplay/MiriGraphics/Api/MiriGraphics/CMiriGraphicsScreenStack.h.
  3. The built-in default theme ("Mowo Default").

The default theme defines eight colors taken from the editor palette: accent, success, warning, error, info, text, textbright and surface, plus the fonts body (Geist 14) and heading (Sora 22).

Token names are normalized before lookup. A path prefix is dropped and the rest is lowercased, so token/accent, Assets/UI/Game.theme.accent and the legacy name AccentColor all resolve to accent Engine/Source/Gameplay/MiriGraphics/Api/MiriGraphics/FMiriGraphicsTheme.h.

Tip

In the UI Designer, color rows offer the theme's token list before a raw color picker. Prefer tokens: a screen authored in raw colors stops following the theme when the theme changes.

Brushes

A Border or Button can describe its look as a brush instead of a flat colour. A brush sits inside the widget next to its props and is named for the part it paints: Border reads "background", Image reads "image", and Button reads one brush per state ("normal", "hovered", "pressed", "disabled", "focused", "selected"). A state with no brush falls back to "normal"; a button with no brushes keeps the look its colours give it.

Text
Brush "background" {
	fill: "accent"
	radii: vec4(4, 4, 8, 8)
	border_width: 1
	border_color: "#ff000080"
	shadow: "elevation2"
	Shadow { offset: vec2(0, 2) blur: 6 spread: 0 color: "#00000066" inset: false additive: false }
	Gradient { type: "linear" angle: 90 Stop { at: 0 color: "accent" } Stop { at: 1 color: "#000000" } }
	opacity: 0.9
	backdrop_blur: 16
}

Radii run top-left, top-right, bottom-right, bottom-left. Opacity multiplies every colour the brush draws. Shadows draw first, then the fill (a gradient replaces the solid colour), then the border. A field that names a token takes the theme's token of that kind (radii, shadow and gradient); a colour field then tries colour tokens, and anything left is a literal (#rrggbb or #rrggbbaa). A brush with plain radii, no border, shadow or gradient and full opacity paints exactly as a flat rounded colour did before.

A theme gains four token kinds beside colours, fonts and metrics: Radii, Shadows (layers of offset, blur, spread, colour and inset), Gradients, and Motion (a duration in seconds and an easing name). A screen transition without its own duration or easing reads the screen entry. The built-in theme defines the shadows elevation1, elevation2 and elevation3, and the glows glow1 and glow2.

Glow

A shadow layer with additive: true is a glow. It draws with the same soft falloff as any shadow, but the falloff scales its colour (and its alpha) and the result is added to what is already on screen instead of blended over it, so a glow lights the pixels behind it, fades to nothing at the edge of its blur and never darkens anything. It leaves the alpha already in the target alone. Offset it by zero and give it a bright colour (the built-in glow1 and glow2 use the accent colour) to make a button or a health bar shine. Glow layers run in the same pass as the ordinary shadows, so the order inside Shadow blocks is the order they stack in.

Backdrop blur

backdrop_blur: <pixels> on a brush draws a blurred copy of the game scene behind the widget, clipped to the brush's rounded rectangle, then the fill over it. Give the fill a translucent colour and the widget reads as frosted glass. The order is shadows, blurred backdrop, fill, border.

  • A radius of 24 or less uses the quarter-resolution blur; a larger one uses the eighth-resolution blur, which is softer and cheaper. 0 turns the blur off.
  • The blur copies the scene as it was when the game view finished, before the UI, so a panel never blurs another panel or itself.
  • The blurred images exist only while a screen asks for them: the engine builds them after the frame in which a brush first paints a backdrop, and stops 30 frames after the last one. The first frame of a new glass panel therefore shows the fill alone.
  • A widget whose brush has a backdrop is never retained across frames, because the picture behind it changes every frame, and an offscreen layer that holds one is redrawn every frame instead of reused.
  • The backdrop samples the whole window, so it draws nothing while the game view does not fill the window (split-screen, a letterboxed viewport).
  • A backdrop that is not painted (a transparent fill, a missing blur image) does not ask the engine to build the blur.
  • The editor's own UI never uses a backdrop or a glow.

Material brushes

material: "Assets/UI/Materials/Dissolve.mat" on a brush fills the widget with a UI material (a material graph whose Output node is in the UI domain) instead of a colour. The MaterialParams block sets the parameters the graph declares, a number for a scalar and a vec4 (or vec3) for a vector; a parameter you leave out keeps the graph's default.

Text
Brush "background" {
	material: "Assets/UI/Materials/Dissolve.mat"
	radii: 8
	MaterialParams { Dissolve: 0.25 Tint: vec4(1.0, 0.55, 0.15, 1.0) }
}
  • Every parameter is a bindable property named material.<name> (material.Dissolve), so a binding or an animation track can drive it per frame. It applies to a Border; a binding on another widget logs one warning and the widget keeps the parameters its brush authored. A name the material does not declare is ignored with one warning.
  • The material draws as one quad over the widget's rectangle and still takes the brush's shadows, backdrop and border; the corner radii do not clip the material itself.
  • A widget whose brush has a material is never retained across frames, because the material animates with time.
  • The material's shader is compiled with the project. In the editor a missing one compiles on demand and the widget draws nothing until it lands; a packaged game that was cooked without it logs one warning and draws nothing.
  • A texture the material names that has not finished loading draws as white; when it lands the mounted screens rebuild once and pick it up. A material that fails to resolve (missing file, wrong domain) is remembered as failed until the game restarts, so it costs one warning, not one per widget.

Sprites and the atlas

A brush with image: "<path>" draws a picture. Pictures that are at most 256 pixels on both sides are packed into one shared 2048 by 2048 sprite atlas page, so thirty different icons are one texture and one draw call, not thirty. Nothing is allocated until the first small image is used: the 16 MiB page is created then, and a game that draws no small images never pays for it. A larger image, a tiled image, or any image that arrives after the page is full is its own texture, and the engine logs one warning when the page fills. Sprites are never evicted.

Each packed image sits in a slot with two pixels of its own edge colour around it, so linear filtering at its edge never picks up a neighbour. A brush that shows a sprite carries the sprite's UV rectangle; the stretched, rounded and nine-slice paths all honour it, and a nine-slice brush slices inside the sprite, with slice measured in source pixels from its edges. An Image widget with no explicit size takes the sprite's own pixel size, not the page's.

A theme can name sprites, and a brush asks for one with sprite: "<name>":

Text
Sprites {
	Sprite "panel" { image: "Assets/UI/panel.png" slice: vec4(6, 6, 6, 6) size: vec2(48, 48) }
}

Brush "background" { sprite: "panel" }

image is the picture, slice makes the brush a nine-slice, and size is the size the sprite asks for when nothing else sizes it. A brush that sets its own image, slice or image_mode keeps them over the sprite's. A name is looked up first among sprites a game registered with FMiriGraphicsBrushRegistry::RegisterSprite, then in the active theme, then in the built-in theme; a name nobody defines leaves the brush without an image.

SVG images

An image that names a .svg file is drawn from vector art. The engine rasterises it once, at the pixel size it will show at, and packs it into the sprite atlas like any other small image, so a crisp icon costs no more than a PNG. The size is the file's own width and height (or its viewBox) times the UI's pixel density, and each size is cached separately, so the same icon at two scales is two sprites. An icon larger than 256 pixels on a side is its own texture.

The renderer reads a deliberately small subset, the part icon sets use:

  • Elements: path (every command, M L H V C S Q T A Z, absolute and relative), rect (with rx and ry), circle, ellipse, line, polyline, polygon, and g. title, desc and metadata are skipped.
  • Attributes: fill, stroke, stroke-width, stroke-linecap, stroke-linejoin, stroke-miterlimit, fill-rule, fill-opacity, stroke-opacity, opacity, display, visibility, transform (translate, scale, rotate, matrix, skewX, skewY), viewBox and preserveAspectRatio, each also as a style="..." declaration. A picture fits its box and is centred; preserveAspectRatio="none" stretches it.
  • Colours: #rgb, #rrggbb, with or without alpha, rgb() and rgba(), a dozen colour names, and none. currentColor is white, so a brush tint colours the icon.
  • Strokes follow the transform's overall scale, so a non-uniform scale gives a stroke of one width. opacity multiplies each shape it covers; it is not a group layer, so overlapping shapes inside an opacity group show through each other.

Numbers are read as decimal numbers only (no inf, nan or hexadecimal) and every coordinate is clamped to plus or minus one million units; groups nest at most 64 deep, and anything deeper is skipped with one warning. A file the engine cannot read or rasterise is remembered as failed, so a broken icon costs one read and not one per paint. The pixel density is the UI scale of the main window, and a size set with CMiriImageCache::SetSvgScale overrides it.

Anything else, such as gradients, patterns, use, text, style sheets, clipping, masks, filters and dashes, is skipped, and the engine logs one warning for each kind the first time it meets it. A gradient or pattern fill draws nothing.

Style files (.style)

A .style file names looks that several widgets share: one block per interaction state, a brush for each, and an optional sound. A widget takes one with style: "Primary" (and variant: "Large" for a size or emphasis variant); a screen lists the files it uses in styles: [@Assets/UI/Game.style], searched in order.

Text
UIStyle "Game" {
	Style "Base" {
		Normal { Props { corner_radius: 2 } Brush { fill: "surface2" } }
		Hover { Brush { fill: "surface3" foreground: "textbright" } sound: "ui/hover" }
	}
	Style "Primary" {
		parent: "Base"
		widget: "Button"
		Normal { Brush { fill: "accent" foreground: "textbright" } sound: "ui/click" }
		Pressed { Brush { fill: "#000000" } sound: "ui/press" }
		Variant "Large" { Normal { Props { content_padding: 16 } } }
	}
}

The states are Normal, Hover, Pressed, Disabled, Focused and Selected. A style inherits from its parent; the chain is flattened when the file loads, a cycle or an unknown parent is an error, and a chain may be at most 8 styles long. A child's block replaces the parent's brush and sound for that state and overrides props by name. A widget names the only node type that takes the style. A variant overlays the style's own look.

Resolved values apply before the node's own, so a prop or brush the node writes always wins. Only the Normal block's Props apply to the widget. A button paints the brush of the state it is in (Pressed, then Hover, Focused, Selected, else Normal; Disabled first), and its text takes that brush's foreground. A state with no brush uses Normal's.

A state's sound plays when the widget enters that state, through the host's sound hook: the game installs one that plays the name as a sound effect. Nothing plays when no hook is installed.

Limits to know about:

  • Only the Normal block's Props apply to the widget; Props in the other state blocks are stored but ignored.
  • A sound plays when a pointer, press, focus, selection or enabled change moves the button into a state, including Disabled and back. Releasing a click over the button settles back to Hover without replaying the hover sound.
  • A brush's foreground colours text-block labels only; a button whose content is anything else keeps its own colours, and a state needs a Brush for its foreground to count. A state without a foreground shows Normal's, or the label's own colour when Normal has none.
  • A style with widget: set is ignored by nodes of any other type.

Editing a style file

Double-click a .style asset in the Asset Browser to open the style editor. It replaces the generic property editor for .style files, and nothing in the file format changes.

AreaWhat it does
Styles (left)Lists the styles with their parent and variant count. The plus button adds one.
Look (center)Pick a Variant (the style's own look is Base) and a State. The same brush rows as the UI Designer edit that state: fill, label color, gradient, radii, border, shadows and glow, opacity, backdrop blur, material, sprite, image, 9-slice and tile size. Sound and, on Normal, the Props table sit below.
Details (right)Rename the style, pick its Parent and Widget, remove it, and see six swatches painted from the resolved look of the selected style and variant. A swatch with no brush says so.

A property value you type becomes a number, true or false when it reads as one, and text otherwise. A state that ends up with no brush, props or sound is not written, except the Normal state of a style or variant you just added. A variant cannot be named Base, which names the style's own look. The material, image and sprite pickers list the project's materials, images and the sprites of the default and project themes. A color field takes #rrggbb, #rrggbbaa or a theme color token and refuses an unknown token. Each change is one undo step.

The editor checks the whole file after every change. A parent that would make a cycle, name an unknown style, or run deeper than eight styles is refused, the reason shows under Details, and the document and the file on disk stay as they were. Save checks again and refuses to write an invalid file. A file that already has such a problem still opens, with the reason shown under Details, so you can repair it in place.

Editor themes

The editor's default theme is Dark. The editor's Preferences > Appearance > Theme also offers Light and High Contrast, which replace the colour tokens; a project can add its own theme as a JSON file of colour tokens under Config/Themes. High Contrast drops elevation shadows, because popups there rely on their outline.

Using tokens in C++

An editor extension that draws its own widgets reads the editor palette from the Miri::Mowo namespace. ToFontInfo turns a typography entry into a Miri font description Engine/Source/UI/Miri/Api/Miri/Mowo/MiriMowoStyle.gen.h.

StatusLabel.cpp
#include <Miri/Widgets/MTextBlock.h>
#include <Miri/Widgets/MBorder.h>
#include <Miri/Mowo/MiriMowoStyle.gen.h>

const Miri::MiriColor warningText = Miri::Mowo::MowoColors::WarningText;
const float radius = Miri::Mowo::MowoMetrics.Radius.Small;
const float fadeMs = Miri::Mowo::MowoMotion.Fade.DurationMs;

Miri::TSharedPtr<Miri::MWidget> label = MiriNew(Miri::MTextBlock).Text(Miri::CText::FromString("Unsaved changes")).Font(Miri::Mowo::ToFontInfo(Miri::Mowo::MowoTypography.Caption)).ColorAndOpacity(warningText);

At run time, CMiriStyle::Get() is the registry of style sets: RegisterStyleSet, SetActiveStyleSet, GetColor(key), and a change listener Engine/Source/UI/Miri/Api/Miri/Style/CMiriStyle.h. With no set registered it falls back to a built-in dark theme, so widgets can resolve defaults before initialization.

Density

The editor's Preferences > Appearance > Density offers Compact, Default and Comfortable. Metric tokens hold the Default values. A widget that lays out from a row height, control height or padding asks CMiriDensity for the value at the current density, and a density change re-lays out the whole UI without a restart CMiriDensity. Rows move by 4 pixels, control heights by 2, and padding scales by 3/4 or 5/4, so the 4-pixel grid holds.

Motion and reduced motion

Transitions read their duration and easing from the motion tokens. When Reduced Motion is on (the ui.ReducedMotion setting, see Settings and accessibility), Miri skips decorative transitions: non-looping animations jump to their end and popups open without sliding. High Contrast UI (ui.HighContrast) switches the Mowo theme to its high-contrast colours.

Engine sources

This page describes behavior implemented in these files of the engine repository, checked against commit 65e34cc4a.

  • Engine/Source/UI/Miri/Api/Miri/Mowo/MiriMowoStyle.gen.h
  • Engine/Source/UI/Miri/Api/Miri/Style/CMiriStyle.h
  • Engine/Source/Gameplay/MiriGraphics/Api/MiriGraphics/FMiriGraphicsTheme.h
  • Engine/Source/Gameplay/MiriGraphics/Api/MiriGraphics/FMiriGraphicsBrush.h
  • Engine/Source/Gameplay/MiriGraphics/Api/MiriGraphics/FMiriGraphicsBrushRegistry.h
  • Engine/Source/UI/Miri/Api/Miri/Rendering/CMiriSpriteAtlas.h
  • Engine/Source/UI/Miri/Api/Miri/Vector/CMiriSvg.h
  • Engine/Source/Gameplay/MiriGraphics/Api/MiriGraphics/FMiriGraphicsStyle.h
  • Engine/Source/Gameplay/MiriGraphics/Api/MiriGraphics/CMiriGraphicsScreenStack.h
  • Engine/Source/UI/Miri/Api/Miri/Style/CMiriDensity.h

Page feedback

Was this page helpful?