Canvas & Layout
Pins and resizing
A design is not finished at one size. Phones differ, windows resize, a translated label is half as long again. Nox gives you two ways to make a frame hold: auto layout, where the frame places its children, and pins, where each child of a free frame says which edges it holds to. This article is about pins and the limits that go with them.

Pins#
Pins apply to a child of a frame without a layout (the inspector calls that Free). When the frame is resized, each child follows its pins, one along the width and one along the height.
| Pin | In the tools | When the frame grows |
|---|---|---|
| Left / Top | left, top | The child stays where it is. This is the default. |
| Right / Bottom | right, bottom | It keeps its distance from the far edge. |
| Left and right / Top and bottom | both | It keeps both distances, so it stretches. |
| Center | center | It keeps its distance from the middle. |
| Scale | scale | Its place and its size grow in proportion to the frame. |
In the card above, the badge is pinned right, the caption bottom, the track left and right and bottom, the round mark center both ways. The blue bar inside the track is pinned to scale, so it stays at 64% of the track.
- Select a child of a frame whose Layout is Free.
- In the inspector's Pins section, choose H: Left, Right, Left and right, Center or Scale.
- Choose V: Top, Bottom, Top and bottom, Center or Scale. The small picture lights the edges it holds to.
- Drag the frame's handles and watch it follow.

Pin the Pro badge to the top-right of the card and make the progress track stretch with the card's width, staying 28 from the bottom. Then make the card 340 wide.
The agent calls update_nodes. Pins are followed when a frame's width or height changes by hand or through the tools:
{
"changes": [
{"id": "BADGE_ID", "pin": {"horizontal": "right", "vertical": "top"}},
{"id": "TRACK_ID", "pin": {"horizontal": "both", "vertical": "bottom"}},
{"id": "CARD_ID", "width": 340}
]
}Two things to know:
- Pins do not apply to children in the flow of an auto layout. The layout places those. A
freechild of a layout frame can carry pins. - A frame whose size a layout decides (it hugs or fills) does not move its pinned children. Pins answer a resize you or an agent make.
Stretch, scale and keep proportions#

Left and right keeps the margins and lets the proportions go. That is right for a bar or a divider and wrong for a photo or an icon.
Scale keeps the layer at the same part of the frame. Its margins grow with it.
Keep proportions fixes a layer's width to its height. Pinned to both edges both ways, it becomes as large as fits in its own shape. Use it for icons, avatars, portraits and artwork, and for a game's buttons across screens of other shapes.
By hand, open Game UI in the inspector and switch on Keep proportions. For an agent it is keep_ratio: true. With it set, a width given without a height takes the height along.
{"nodes": [{"kind": "frame", "name": "Stage", "x": 0, "y": 0, "width": 160, "height": 120, "fill": "#FFFFFF", "children": [
{"kind": "rectangle", "name": "Picture", "x": 20, "y": 20, "width": 120, "height": 80, "corner_radius": 10, "fill": "#6E9BFF",
"pin": {"horizontal": "both", "vertical": "both"}, "keep_ratio": true}]}]}
Min and max size#
Limits say how far a layout may push a size. min_size and max_size are [width, height]; 0 means no limit on that axis. They apply to a child that fills and to a frame or text that hugs. A fixed size is not limited.

- A text with
width: "hug"andmax_size: [220, 0]grows to 220 and then wraps. - A field with
width: "fill",min_size: [120, 0]andmax_size: [180, 0]takes what its row leaves, between those two widths.
By hand they are Min W, Min H, Max W and Max H under More, below the size fields. An agent sets them like any property:
{"nodes": [{"kind": "frame", "name": "Bubble", "x": 0, "y": 0, "width": "hug", "height": "hug", "fill": "#FFFFFF", "corner_radius": 14,
"layout": {"direction": "vertical", "padding": [8, 12]},
"children": [{"kind": "text", "text": "Running ten minutes late. Save me a seat near the window if you can.", "width": "hug", "max_size": [220, 0], "font_size": 14, "line_height": 20, "fill": "#111318"}]}]}
Text that shrinks to fit#
A button is 140 wide. "Play" fits at 18. "Продолжить игру" does not. You can cut the text, or let it shrink.

A text with a width and a height of its own can be given a least font size. Where its lines do not fit its box at its size, it is shown smaller, in half units, until they fit, and never smaller than the least. The font size you set does not change, so a short label stays large.
- Give the text a fixed box: a width, and Fixed height under More in the Text section.
- In the same place, set Shrink to fit, least to the smallest size you accept, such as 10.
Make the button labels shrink to fit their buttons, never below 10 pt.
The agent calls update_nodes on each label, which must have a width and a height of its own:
{"changes": [{"id": "LABEL_ID", "width": 116, "height": 24, "text_fit": 10, "text_align": "center", "text_vertical_align": "middle"}]}Set the least size no lower than you would accept on a real screen: 10 or 11 for a label, 12 for anything read at length. What still does not fit is cut if the text is set to be cut.
How a design holds at other sizes#
A short checklist before you call a screen done:
- Structure with auto layout. Screens are columns; bars are rows with space between; content fills.
- Pins for what floats. A close button pinned right and top, a floating button pinned right and bottom, a backdrop pinned to all four edges.
- Limits where it matters. A least width on cards and fields, a most width on paragraphs (about 560 for body text).
- Text that copes. Auto height for paragraphs, cut or shrink for labels in fixed boxes.
- Try it. Resize the frame to 320, 390 and 430 wide for a phone, or 1024 and 1440 for a window, and look.
An agent can do step 5 for you: ask it to duplicate the screen at other widths and check each one. Worked examples are in Responsive patterns.