Game UI
Button states
A game button has at least four looks: as it rests, while it is held, when it cannot be used, and when it is the one chosen. In Nox these are the variants of one component set, told apart by a property named State. You draw the button once, add its states in one step, and every instance can show any of them.

What each state is for#
| State | When the player sees it | A look that reads at a glance |
|---|---|---|
| Normal | At rest | The full design: here a gradient from #5B9BFF to #2F6EEA, an 18 radius, a hard shadow 6 below |
| Pressed | While a finger, pointer or controller button is down | Darker (#2F6EEA to #1D4FB8), the label 2 lower, the shadow gone, so the button seems to sink |
| Disabled | When it cannot be used | 40% opacity. It answers to nothing |
| Selected | When it is the chosen one, or has controller focus | A bright ring: a 3 stroke of #FFE9A8, inside |
A game or a phone has no pointer hovering over things, so Add States makes no Hover. A fifth state, Hover, exists for desktop games with a mouse: add it only when you need it.
Add the states#
- Draw the button and select it.
- Choose Arrange › Make Component (⌥⌘K).
- Choose Arrange › Add States. The same command is under a right click on the component, on the canvas and on its row in the layer list.
- Nox makes a component set with the button's name where the button stood. Your button is its Normal, at the top. Under it, 16 apart, are a copy for Pressed, for Disabled and for Selected.
- Redraw each copy. Only Disabled arrives changed, at 40% opacity, so that you can tell it from the others at once.

Run Add States again on a set that lacks a state and only the missing ones are added, under what the set already holds. It is one step to undo.
Ask for the states and say how each should differ. The tool is add_states. It returns the set and the node of every state, and the agent then redraws each with update_nodes.
Give the Play button its states. Pressed: a darker blue, label 2 lower, no shadow.
Selected: a 3 px inside stroke of #FFE9A8. Leave Disabled as it comes.
The agent calls add_states with:
{ "node": "5:2" }
and gets back which states were added and where each one is:
{
"added": ["Pressed", "Disabled", "Selected"],
"set": "5:4",
"states": [
{ "node": "5:2", "state": "Normal" },
{ "node": "5:5", "state": "Pressed" },
{ "node": "5:7", "state": "Disabled" },
{ "node": "5:9", "state": "Selected" }
]
}
Then it calls update_nodes to draw Pressed:
{
"changes": [
{ "id": "5:5", "fills": ["#1D4FB8"] }
]
}
For a desktop game, a second call adds the fifth state: { "node": "5:2", "states": ["Hover"] }.
Show a state on an instance#
Place the button as an instance wherever a screen needs it. The instance shows Normal until you choose another state.
- Select the instance.
- In the inspector, under Component, open the State menu.
- Choose Pressed, Disabled or Selected.

Use this to draw a screen as it really appears: the first item of a menu Selected, a locked level's button Disabled.
Through the tools it is the variant property. This call to update_nodes shows one instance as Pressed:
{
"changes": [
{ "id": "6:15", "variant": { "State": "Pressed" } }
]
}
See them work#
You do not need to wire anything to try the states. In Review (⌘2) and in Play (⌘3) every instance answers the pointer by itself:
- Pressed shows for as long as the pointer is held on the instance.
- Selected shows after a click, and goes after another click.
- Hover shows while the pointer is over it, where the set has that state.
- An instance that shows Disabled answers to nothing.
Each instance keeps its own state, however deep it sits inside other instances. Of two buttons in one card, only the one you press changes. Nothing in the document changes, and nothing is added to the undo history. Leave Review and every instance shows what it showed before.
An agent can look at a state without touching the document. render_preview takes states: a list of instances and the state to draw each in.
{
"node": "6:14",
"states": [
{ "path": ["6:15"], "state": "Selected" }
]
}
Draw states that hold up#
- Change more than color. A player with a color vision deficiency should still tell Pressed from Normal. Move the label, drop the shadow, or change the outline.
- Keep the box the same. Every state should be the same width and height, so a menu does not jump when a button is pressed.
- Selected must be seen from the sofa. On a television the focus ring is the only pointer the player has. Give it 3 units or more and a color that stands off the screen behind.
- Test Disabled on the real backdrop. 40% opacity over a busy level can vanish. Raise it, or add a flat plate behind the label.
Handing the states to code#
inspect on the component or an instance returns state, the one it shows, and states: each state's node with its own CSS and SwiftUI. The CSS ends with a rule for each other state that holds only what that state changes: &:active for Pressed, &:disabled, and &[aria-selected="true"].
For an engine, export each state as its own picture. The four variants share the component's name, so exported together they come out as Play.png, Play 2.png, Play 3.png and Play 4.png. Rename each variant first, to Play-Normal, Play-Pressed and so on, and the files carry the state. See Export for a game engine.