Practical guide
Apply semantic interface styling
Request a validated theme contract and rely on semantic tokens instead of renderer-specific colors.
Procedure
- Choose a stable theme ID owned by the package or first-party interface.
- Set bounded text scale, high-contrast preference, and reduced-motion preference.
- Use registered semantic color roles for meaning rather than hardcoded renderer colors.
- Compose all controls after applying the theme for the current contribution.
- Handle error.invalid-theme by retaining the prior valid graph and correcting the contract.
Example
ui.set_theme({
id = "worldforge.standard",
text_scale = 1.0,
high_contrast = false,
reduced_motion = true
})
Constraints and recovery
- Theme contracts affect presentation only and cannot alter engine or gameplay values.
- Text scaling and reduced-motion metadata must remain usable when a surface is replaced.
- A package should not infer concrete colors from semantic token names.