Controls and layout
Concept: controls form a tree, and layout is decided by size, anchors and stacks
A screen is a tree of controls. Children go in the parent control's controls array, and a child is placed inside its parent by size (size), reference points (anchor_from/anchor_to), movement (offset) and overlap order (layer). If the parent is a stack_panel, children are stacked in one direction, and if it is a grid, they are placed in cells.
A working example
An info card attached to the top right of the screen. A title label and a body label are inside a vertical stack, and the card shrinks to fit its children.
{
"namespace": "my_addon",
"info_card": {
"type": "panel",
"size": ["100%c + 8px", "100%c + 8px"], // Sum of children + margin
"anchor_from": "top_right", // Attach to the parent's top right
"anchor_to": "top_right", // and align its own top right
"offset": [-4, 4], // Push inward (for a right anchor, negative x is inward, LAY-17)
"controls": [
{ "bg": { "type": "image", "texture": "textures/ui/white_icon",
"color": [0, 0, 0], "alpha": 0.6, "layer": 1,
"size": ["100%sm", "100%sm"] } }, // A background matched to the largest sibling
{ "rows": {
"type": "stack_panel", "orientation": "vertical", "layer": 2,
"size": ["100%c", "100%c"],
"controls": [
{ "title": { "type": "label", "text": "Title", "color": [1, 1, 0] } },
{ "body": { "type": "label", "text": "Body", "size": ["default", "default"] } }
] } }
]
}
}
The size "100%c" is the sum of visible children and "100%sm" matches the largest sibling (LAY-03, LAY-07). Giving the background a low layer guarantees front and back order (LAY-19).
The Bedrock Wiki property table (with defaults)
Excerpt: JSON UI Documentation, Control and Layout properties · docs/json-ui/json-ui-documentation.md · Bedrock Wiki · License CC BY 4.0 (docs/licenses/CC-BY-4.0.md in the repository) · Commit 0930b39
Property Type Default Description visible boolean trueIf the UI element should be visible enabled boolean trueIf true and the element or any child has the locked state then they will be in the locked state layer int 0Z-Index relative to the parent element. Higher values render above, negative values render below the parent element alpha float 1.0Alpha of the element. It will only affect the UI element. Its children will be unaffected. Use propagate_alphato apply to children toopropagate_alpha boolean falseIf alphashould apply to all children as wellclips_children boolean falseCuts off visually and interactively everything beyond the boundaries of the UI element allow_clipping boolean trueIf clips_childrenof an ancestor works on this elementuse_child_anchors boolean falseUse the anchor_fromandanchor_toof the children of the UI elementgrid_position Vector Position that the control will take inside the grid. Also allows modifying specific grid items of a hardcoded grid collection_index int Index that the control takes in the collection size Vector [width, height] ["default", "default"]"default", a number of pixels (0or"0px"), a percentage of the parent ("50%"), and sums such as"100% - 4px"max_size, min_size Vector ["default", "default"]Maximum and minimum size the element can have offset Vector [x, y] [0, 0]Position relative to the parent, based on the top left corner anchor_from enum centerAnchor point in the parent element anchor_to enum centerAnchor point in the element orientation enum verticalDirection the elements stack inside stack_panel(vertical,horizontal)grid_dimensions Vector [columns, rows] Number of columns and rows the grid has maximum_grid_items int Maximum number of items the grid will generate grid_item_template string An element capable of handling collections Anchors allow the elements to align to a certain point.
anchor_tois the anchor point in the element that will be attached to theanchor_fromin the parent element. Foranchor_from: centerandanchor_to: top_left, the top left point of the element is in the center point of the parent element.
Note: the "default" size differs per type (LAY-03). grid_position is [column, row] (LAY-29). Vanilla uses only vertical for grid_fill_direction (LAY-26). allow_clipping is inherited from the parent when omitted, and is true only for a control without a parent (LAY-68).
The element property reference of Microsoft Learn
The MS Learn minecraft:ui_element document (commit a9fd1c0) lists element properties by name, type and description (Source: ms-learn). The main items this wiki treats as rules are as follows.
| Category | Properties |
|---|---|
| Size and placement | size ([width, height], numbers are pixels, '100%', 'fill', '100%c', '100%cm'), min_size, max_size, offset ([x, y] pixels), anchor_from, anchor_to, layer (higher is on top), orientation |
| Display | visible, alpha (0.0~1.0), propagate_alpha, color ([r, g, b]), clips_children, allow_clipping, ignored, shadow, grayscale |
| Texture | texture, uv, uv_size, tiled, keep_ratio, bilinear, nine_slice_left/top/right/buttom (original spelling), fill |
| Text | text, text_alignment, font_size, font_type, font_scale_factor, max_length, place_holder_text |
| Collection and grid | collection_name, grid_dimension_binding, grid_item_template, grid_rescaling_type, factory, bindings, variables, controls |
| Input and focus | button_mappings (from_button_id, to_button_id, mapping_type, input_mode_condition), focus_enabled, focus_change_up/down/left/right, default_focus_precedence, modal, consume_event, prevent_touch_input |
| Scroll and slider | scroll_content, scroll_view_port, scrollbar_box, scrollbar_track, scroll_speed, slider_range, slider_steps |
| Accessibility | tts_control_type_order_priority, tts_ignore_count, tts_skip_message |
The enum tables of this document (types, anchors, etc.) are empty and some names (scrollbar_track, nine_slice_buttom) differ from vanilla. Judge types by vanilla usage (the control types table below) (LAY-01). The scroll track type is scroll_track.
Rules
Evidence from Cinnabar (CN, Rust code that reconstructs the JSON UI parser of the 26.30 native client) has the level code, and CN-run is the result of this project running that evaluator directly. If it differs from game measurement, follow measurement. DF was measured on Windows 1.26.52 while building the research server, in a structure that draws several screens with one server form. FFR was measured on mobile with the server form factory and lag test add-on (2026-11-14). The add-on setup is in Server form research screen. LAY-59~LAY-68 are layout rules read from the native client decompilation (NB, Windows 1.26.65.1 and Android 1.26.52.3) and measured in game on Windows 1.26.65.1 (2026-11-20). The measuring window is the test window juc_tester.json of the add-on addons/json-ui-claims (server form title §b§wjc:t, opened with /scriptevent bwiki:json_ui_claims t), and the setup is in claim measurements. LAY-69~LAY-71 are read from a decompilation of the Windows 1.26.65.1 client (2026-11-24). The same day's measurements are in section 6.8 of claim measurements, and LAY-69 and LAY-70 were not measured in game.
Control types
These are the values used as "type" in vanilla 1.26.50.4 and their counts (VN exhaustive search). Note that they differ from the official enum (forms/ui/ui_element.form.json).
| Type | Vanilla | Official enum | Use |
|---|---|---|---|
panel | 4,092 | O | An empty box. Child placement, binding host |
stack_panel | 1,461 | O | Stacks children in one direction |
image | 1,318 | O | Texture |
label | 814 | O | Text |
grid | 132 | O | Grid, collection |
input_panel | 108 | O | A panel that receives input (hover, drag, modal) |
custom | 105 | O | What the engine draws through renderer |
button | 54 | O | Button (mostly written with the common_buttons.* templates) |
factory | 36 | X | A factory control that creates controls per kind of data (collections and factories chapter) |
screen | 7 | O | Screen root |
collection_panel | 3 | X | Collection + factory host |
scroll_view, scrollbar_box, scroll_track | 2, 1, 1 | O, O, X | Scroll components |
edit_box, toggle, slider, slider_box, dropdown | 2, 1, 1, 1, 1 | O | Mostly used through templates |
tooltip_trigger, selection_wheel, label_cycler, image_cycler, grid_page_indicator, carousel_label | 2, 1, 1, 1, 1, 1 | X | Special |
- [LAY-01] Judge the list of valid types by vanilla usage, not by the official enum. The official enum is missing types vanilla uses, such as
factory,collection_panel,tooltip_triggerandscroll_track. The scroll track type isscroll_track(scrollbar_trackis not a type), and the legacy typestab,grid_itemandscrollbarnever appear in vanilla.carousel_label, which the wiki classifies as legacy, remains once in vanilla, but the Windows 1.26.65.1 engine rejects it as an unknown type and does not create it (ANI-46).{vanilla, measured}(Source: VN, BC-facts official schema section, BW-doc, 2026-11-20 Windows 1.26.65.1) - [LAY-02]
scroll_boxis not a type but a control name inui_common.json. Do not assemble scrolling by hand; reuse thecommon.scrolling_paneltemplate with variables such as$scrolling_content.{vanilla, working pack}(Source: VN server_form.jsonscrolling_panel@common.scrolling_panel, BA chapter 5, AP, MJ 4.2-2) - [LAY-70]
screen_not_flushableis a boolean read only bytype: screencontrols and defaults to false. The value is stored as a bit of the screen component and a screen getter returns that bit, but the screen stack code that calls the getter was not found. From the name it looks like a mark that keeps this screen when the screen stack is flushed all at once, but the effect is inferred.{code (binary), inferred}(Source: 2026-11-24 Windows 1.26.65.1 decompilation)
Size
| Notation | Meaning | Vanilla |
|---|---|---|
16 or "16px" | Pixels | px 2,606 |
"50%" | A ratio of the parent size | many |
"100%c" | Size based on children. In both stack panels and plain panels, the sum of visible children (grids: LAY-03) | 2,201 |
"100%cm" | The largest child | 419 |
"100%sm" | The largest sibling | 263 |
"100%x", "100%y" | A ratio of its own other axis size (square, fixed ratio) | 162, 150 |
"fill" | The remaining space in a stack panel | 668 |
"default" | The default size of the content (label text, etc.) | 963 |
"100% - 4px", "100%c + 12px" | Expression | %c + 288 |
- [LAY-03] Use the size keywords in the table above. The meaning "based on the other axis" for
%x/%ywas judged from a vanilla comment (25%x * 56.25%) and usage."default"was the same as an omitted size and differs by type. Measured on Windows 1.26.65.1, a panel was 100% of the parent, a label the text size (Hello24x10), a vertical stack panel 100% of the parent wide and the sum of its children high, and a grid the extent of its children (a 2x2 grid of 10x10 cells was 20x20) (claim measurements). Only a panel equals"100%"on both axes. In the code this grid size is not the extent of the children but dimensions x template size, so the value is the same but it is measured by the dimensions even when there are fewer items than the dimensions (2026-11-24 decompilation). In the Cinnabar reconstruction, an omitted size is100%cif it is the main axis of a stack panel, the texture ratio for a ratio image, and the parent size otherwise (LAY-38). In size expressions%cand the like are written after%(LAY-36).{vanilla, code (source), code (binary), inferred, measured}(Source: VN store_search_screen.json:64 comment, VN exhaustive search, BW-doc, CN, 2026-11-18 Windows 1.26.65.1, 2026-11-24 Windows 1.26.65.1 decompilation) - [LAY-04] A stack panel gives no space to hidden (
#visiblefalse) children. Collapsing a conditional row pulls what is below up, and turning power-of-two spacers on and off makes the sum the coordinate (pattern recipe 6).{working pack, measured}(Source: BA chapter 4, BC-S12) - [LAY-05] The position (
offset) of a static control changes when a view binding copies aproperty_bagkey that holds an array to#offset. In the Windows 1.26.65.1 HUD, a label with a static"offset": [70, 0],"property_bag": {"#o": [10, 20]}and a view binding from#oto#offsetmoved to the (10, 20) GUI position (it replaced the static offset). A label with only"#offset": [10, 20]inproperty_bagand no binding stayed at its static[30, 0]position. The Cinnabar reconstruction also accepts an[x, y]binding on#offset. The code is the same: when the#offsetproperty bag key holds an array, [0] and [1] are read as floats, the offset becomes two pixel terms and layout is redone. If it is not an array, (0, 0) is used, and nothing happens when that equals the current expression. A binding expression only yields a boolean, integer, float or string, so an expression cannot compute an array. So for a position that changes with a value, bind the size of a spacer placed before it so the stack pushes the next child.{measured, working pack, code (source), code (binary)}(Source: BC-S12, BA chapter 4, CN, 2026-11-24 Windows 1.26.65.1 decompilation, 2026-11-25 Windows 1.26.65.1) - [LAY-06] Make responsiveness with
max_sizeandmin_size. Example: with"size": [314, "100% - 64px"]and"max_size": [314, 236], the window height shrinks on small screens.{working pack, vanilla}(Source: BA chapter 5, VN max_size 204 uses) - [LAY-07] If you put a background as
"100%sm"inside a"100%cm"box, when a row inside hides, the box and background shrink together and what is below follows up.{measured}(Source: BC-S12) - [LAY-08] If you put a label and a
"100%sm"button inside a"100%cm"panel, the button hitbox fits the text size exactly in each language. Using"100%c"in the same place makes the button fall below the label.{measured}(Source: BC-S10) - [LAY-09] When putting an icon-only button in a row whose height is set by its children, give an explicit square size. A percentage height does not decide the row height.
{measured}(Source: BC-rules) - [LAY-34] The size keywords
"fill"and"default"are keywords only when exactly in lowercase. A unitless numeric string ("10") becomes 0. Write it as a number or as"10px". A space is not a separator, and the last number remains after a term is made (LAY-63).{code (source)}(Source: CN-run) - [LAY-35] The sign in a size expression carries on to the next sign:
"100% - 10px 5px"is 100% - 15px. Write a sign on every term.{code (source)}(Source: CN-run) - [LAY-36]
%c,%cmand%smare written after%."100c%"and"50c%"in vanilla progress_screen.json are read as parent-based%. On Windows 1.26.65.1, inside a 210-wide parent, a["100c%", 10]panel (child 30x10) was 210x10 and a["50c%", 4]panel was 105x4. In the code the parser treats only the token after%as a modifier and ignores a separatec.{vanilla, code (source), code (binary), measured}(Source: VN progress_screen.json:21, 31 and 48, CN-run, 2026-11-24 Windows 1.26.65.1 measurement and decompilation) - [LAY-37]
%cmand%smignore the coefficient and are the maximum value itself."50%cm"is also the largest child size. On Windows 1.26.65.1, a["50%cm", 10]panel was 90 wide with children 30 and 90 wide (not half 45, not half the sum 60, not a fixed 50), and[10, "50%cm"]was 30 high with children 10 and 30 high.["100%cm", "100%cm"]was 40x20 with children 30x10 and 40x20. In the code a%cmterm stores no coefficient or sign and is the maximum of the child sizes (starting at 0). If you need half, shrink again with%in a wrapping panel.{code (source), code (binary), measured}(Source: CN-run, CN tests G06 and G07, 2026-11-24 Windows 1.26.65.1 measurement and decompilation) - [LAY-64]
%cmignores the sign as well as the coefficient (LAY-37)."50px - 100%cm"with a 20-wide child was 70. A%cmterm is added even with a-in front of it.{code (binary), measured}(Source: NB, 2026-11-20 Windows 1.26.65.1) - [LAY-63] In a size string a space is not a separator, and the last number remains after a term is made and is reused by the next unit. In a 100-wide parent,
"50px%"and"50px %"were both 50px + 50%, which is 100, and"10px px"was 20. Write a number for every unit (LAY-34, LAY-35).{code (binary), measured}(Source: NB, 2026-11-20 Windows 1.26.65.1) - [LAY-61] A size value must be an array. A non-array value such as
"size": 20makes both axesdefault, and the panel was 100% of the parent. To give both axes the same value, write[20, 20].{code (binary), measured}(Source: NB, 2026-11-20 Windows 1.26.65.1) - [LAY-59] The
100%cof a plainpanelis also the sum of the sizes of its visible children. A panel with children of 30x10 and 50x20 and a hidden 40x40 was 80x30. Even when children overlap it is a sum, not an extent, so use100%cmto fit the largest child (LAY-52). On 2026-11-24 a["100%c", "100%c"]panel with children 30x10 and 50x20 was also 80x30. In the Windows 1.26.65.1 code,%cof every non-grid type adds a "coefficient x child size" term per child (a grid uses dimensions x template size), and hidden children (JSONvisiblefalse, hidden by a binding) have a size node of 0 and drop out of the sum.{code (binary), measured}(Source: NB, 2026-11-20 Windows 1.26.65.1, 2026-11-24 Windows 1.26.65.1 measurement and decompilation) - [LAY-39] Minimum and maximum are applied as: the maximum if the value is above it, otherwise the larger of the value and the minimum. So if minimum and maximum conflict (
min > max), a value above the maximum is clipped to the maximum, and a value at or below the maximum gets the minimum. On Windows 1.26.65.1, size 10 with minimum 50 and maximum 30 gave 50.filloutside the stack's main axis is 0.{code (source), code (binary), measured}(Source: CN, NB, 2026-11-20 Windows 1.26.65.1) - [LAY-62]
min_sizeandmax_sizealso accept child-based terms such as%c. A control with"min_size": ["100%c", 0]and a 30-wide child was 30 wide.{code (binary), measured}(Source: NB, 2026-11-20 Windows 1.26.65.1) - [LAY-65] Several
fillchildren on a stack's main axis split the remaining space equally. In a 100-wide horizontal stack with a fixed 20 child and twofillchildren, thefillchildren were 40 and 40.{code (source), measured}(Source: CN, 2026-11-20 Windows 1.26.65.1) - [LAY-66] A stack's
orientationreads only the lowercasehorizontalandvertical. A value with different case such as"Horizontal", or an unknown value, stacked vertically.{code (binary), measured}(Source: NB, 2026-11-20 Windows 1.26.65.1) - [LAY-40] With a stack's
use_priority: true, when the sum of children overflows, children with the lowestpriorityare kept first (0 or lower always kept) and children that do not fit are hidden.{code (source)}(Source: CN test S05) - [LAY-72] On a child of a
use_priority: truestack,"priority_rule": "show_when_controls_are_hidden"takes the child out of the overflow count (LAY-40) and shows it only when another child overflowed and was hidden. Use it for a "more" marker. In a 100 wide horizontal stack with three 40 wide labels (priority1, 2, 3) and a 20 wide marker, the third label was hidden and the marker shown. With only two labels everything fit and the marker was hidden. Given to an ordinary child, the child is hidden unless another child is hidden. It had no effect in a stack withoutuse_priority, and it was hidden along with the HUD on F1. The other value isdefault.{measured, code (binary)}(Source: 2026-12-03 Windows 1.26.65.1 measurement and decompilation) - [LAY-69] A control with
inherit_max_sibling_width: truecomputes its width and then takes the largest of its own width and the widths of all the parent's children (itself included) that have a layout.inherit_max_sibling_heightdoes the same on the height axis. Both are booleans read by every control and default to false. There is no visibility check, but a hidden sibling has a size node of 0 and has no effect. Whethermin_size/max_sizeis applied again to the result, and how many passes run when two siblings both turn it on, is unknown.{code (binary)}(Source: 2026-11-24 Windows 1.26.65.1 decompilation) - [LAY-51] Putting two columns as two vertical stacks in a horizontal
stack_panelgave height 0. Put two vertical stacks attached to the top left and top right inside apanel(height100%cm).{measured}(Source: DF) - [LAY-52] With a left panel and a right detail in a horizontal stack,
100%cadded the two heights and100%cmcollapsed the right detail. Put the panels inside apanelwith a top-left reference andoffset, and give thatpanela height of100%cm(the largest child) (LAY-51). The100%cof a plainpanelis also the sum of visible children, so it adds the two heights (LAY-59).{measured}(Source: DF, 2026-11-20 Windows 1.26.65.1) - [LAY-53] Fitting the window height to the content with
100%cmade the window and content refer to each other and collapse (buttons went outside the window). Keep a server form window at a fixed pixel size and handle overflowing content with an innerscrolling_panelor server-side paging. Phones draw the UI large, so a window bigger than the vanilla inventory (326x166) does not fit on screen.{measured}(Source: DF) - [LAY-54] Making a list cell the content height (
100%c + 8px) made an empty list a thin bar and let a long list go outside the window. Fix the list cell to the window height and putcommon.scrolling_panelinside it. If you fix a button cell at a fixed height, a scrollbar appears when a body is attached above it, so use astack_panel100%cso that it takes only as much as the buttons.{measured}(Source: DF)
Size, position and opacity bindings
- [LAY-10] A size binding writes values to
#size_binding_xand#size_binding_y. The value is a multiple of the parent size, not pixels. Measured on Windows 1.26.65.1, a declared 10x10 child in a 100-wide parent got width 50 for .5 and width 200 for 2, past the parent, and#size_binding_x_absolute20 gave 20 (claim measurements). The Cinnabar reconstruction does the same (value v becomesv x 100%,_absoluteis pixels). So inside a[1, 1]size frame the value becomes pixels. Keep the declaration as["100%", "100%"]. With a[0, 0]declaration an unbound axis stays 0 and nothing is drawn (LAY-11). Vanilla's only size binding (resizing_xp_bar_with_hotbar) is used withuse_anchored_offset: true, but on a static control the result was the same 50 without it (measured on Windows 1.26.65.1). Avoid the combination of a size binding +use_anchored_offset+ a collection cell (LAY-14). The offset binding#anchored_offset_value_x(use_anchored_offset: true) was a multiple of the parent width in game: 50 in a[1, 1]frame and 0.5 in a 100-wide frame both landed at 50px, and 50 in a 100-wide frame went outside the frame. This matches the parent size reading; to move by pixels, put the control in a[1, 1]frame.{measured, code (source)}(Source: BC-S6, BC-S12, BW-doc, VN hud_screen.json:319, CN, CPR, 2026-11-18 Windows 1.26.65.1) - [LAY-11] A size binding binds both axes. If only one axis is bound, the other axis becomes 0 and it looks as if the binding failed. An unbound axis keeps its declared value (Cinnabar reconstruction), so if the declaration is
[0, 0]that axis stays 0.{measured, code (source)}(Source: BC-S12, CN) - [LAY-12] What can be bound where depends on where the control was created. A size binding on a static control did not need
use_anchored_offset(Windows 1.26.65.1 measurement).{measured}(Source: BC-S12, BW-doc, 2026-11-18 Windows 1.26.65.1)
| Property | Static control | A cell created by a computed length factory | A cell of the engine form_buttons factory |
|---|---|---|---|
#size_binding_x/y | works | does not work | works |
#anchored_offset_value_x/y (+ use_anchored_offset: true) | works only with a corner anchor (a multiple of the parent size, measured on Windows 1.26.65.1, LAY-49) | does not work | works |
"alpha": "#alpha" | the float as is (LAY-13) | - | the float as is in the code, not measured in game (LAY-13) |
visible, text, #collection_length | works | works | works |
- [LAY-13] A bound
alphaapplies as the float it is. On Windows 1.26.65.1, a white image over a black image with"alpha": "#alpha"and 0.5 fromproperty_bagpassed through a view binding had a center pixel of (128,128,128), and a static"alpha": 0.5was also (128,128,128)..2,.5and.9also each drew with a different transparency. In the code#alphais read as a float and stored without clamping. Integers and floats give their value, booleans give 1.0 and 0.0, and strings (including numeric strings), arrays, objects and a missing key give 1.0. With only the view binding target set to#alphaand no declaration, even the integer 1 was invisible (measurement record). An expression of constants only ((1 * .5)) has no#property, so the binding is dropped and alpha stayed 1; pass the value through a#property (BND-05).{measured, code (source), code (binary)}(Source: BC-S12, CN, 2026-11-19 Windows 1.26.65.1, 2026-11-24 Windows 1.26.65.1 measurement and decompilation) - [LAY-14] The combination of a size binding +
use_anchored_offset+ a collection cell crashed the client twice on a chest screen. Avoid this combination.{measured}(Source: BC-S6) - [LAY-15] When the size binding value changes while the screen is open, layout is redone. In the code, when a
#size_binding_*value changes the size expression, the size node is marked dirty and recomputed; if the expression is the same, nothing happens. This was not measured in game.{code (binary)}(Source: BC-S6, BC chapter 8, 2026-11-24 Windows 1.26.65.1 decompilation)
Anchors and offsets
- [LAY-16]
anchor_fromis the parent's reference point andanchor_tois its own reference point. The values are 9:top_left,top_middle,top_right,left_middle,center,right_middle,bottom_left,bottom_middleandbottom_right.{vanilla}(Source: VN all 9 used, value dictionary) - [LAY-17]
offsetis movement relative to the anchor and uses the same units as size (pixels,%, expressions). Example:"offset": [0, "50%-68px"]. The axis is not flipped even for right and bottom anchors: in the distribution over 206 vanilla files, the x of right anchors is negative 104 to positive 37 and the y of bottom anchors is negative 190 to positive 45, andcommon.close_buttonuses[-2, 2]with atop_rightanchor (ui_common.json:3239-3246).{vanilla}(Source: VN hud_screen.json:2146, ui_common.json:3239-3246) - [LAY-43] An anchor value is read only when it equals one of the 9 names (LAY-16) exactly, including case; any other string is
center. On Windows 1.26.65.1,left,top,middle_leftandTop_Leftall landed at the center. The Cinnabar reconstruction, which decides by whether the name containsleft,right,toporbottom, differs from the game.{code (source), code (binary), measured}(Source: NB, CN, 2026-11-20 Windows 1.26.65.1) - [LAY-60] An omitted
anchor_toiscenter. A control given onlyanchor_from: "bottom_right"had its own center on the parent's bottom right point. To attach a corner, writeanchor_towith the same name too (LAY-45).{code (binary), measured}(Source: NB, 2026-11-20 Windows 1.26.65.1) - [LAY-38] Children of a stack panel ignore
offset, and ignore anchors too unlessuse_child_anchors: true. The main axis size of an omitted stack panel is100%c.{code (source)}(Source: CN test S04, CN) - [LAY-56] The
offsetgiven tostack_panelchildren did not move the position the stack decided. When 48 cells were put in a horizontal stack and folded per row withoffset, they ran in one line out of the window. For 2D layout, put horizontal stack rows inside a vertical stack.{measured}(Source: FFR)
Layers and draw order
- [LAY-18]
layeris a relative value to the parent. To know which of two overlapping controls is in front, you must compare the layers of the whole ancestor chain. In the code the absolute layer is the parent's absolute layer + its own value (integer).{measured, code (binary)}(Source: BC-rules, 2026-11-24 Windows 1.26.65.1 decompilation) - [LAY-19] There is a measurement record that for siblings on the same layer, array order does not guarantee draw order. In the code, draw items are stable-sorted by absolute layer in ascending order, and equal values keep tree preorder (array order). So siblings with the same absolute layer are predicted to draw in array order, with the later sibling on top. The measurement that looked unordered may have had different ancestor layer sums (inferred). The order of siblings with the same absolute layer was not measured separately in game, so if front and back matter, give different layers.
{measured, code (binary)}(Source: BC-rules, MJ 4.2-10, 2026-11-24 Windows 1.26.65.1 decompilation) - [LAY-20] If the same data must be drawn in the order "all outlines, then all lines, then all nodes, then hover", raising layers within one item is not enough (the next item's outline covers the previous item). Draw the same collection several times with factories on different layers.
{working pack}(Source: BA chapter 5) - [LAY-21] Layers of 50 or more are common in vanilla too. A warning that the layer is high can be ignored. The 2026-11-24 decompilation found no code for a layer limit or a warning, and the layer was used as the integer sum.
{vanilla, inferred}(Source: MJ chapter 5, 2026-11-24 Windows 1.26.65.1 decompilation) - [LAY-33]
alphamakes only that control transparent and is not propagated to children. To make children transparent too, givepropagate_alpha: true(BND-15).layermay be negative and then draws below the parent. The code agrees.{code (binary), vanilla}(Source: BW-doc Control table, 2026-11-24 Windows 1.26.65.1 decompilation) - [LAY-67]
layeris read only as an integer. Writing it as a string such as"layer": "5"gives layer 0.{code (binary), measured}(Source: NB, 2026-11-20 Windows 1.26.65.1) - [LAY-55] When the label of a cell created by a factory or grid inside a scroll area was put on the same layer as the background image (default 0), icons and progress bars showed immediately but text was empty until something touched it (sometimes only the touched cell appeared). Putting the label on a layer higher than the background (icon 2, label 3) made everything visible as soon as it opened. Vanilla button labels are also
layer: 2.binding_condition, having an expression or not, having a factory or not, clipping and scroll refresh had nothing to do with this symptom.{measured}(Source: FFR) - [LAY-58] When a label and the fill under it have the same ancestor layer sum, the fill can cover the label. In the chest screen gallery the PlayerList names (sum 14), the Badge counts (sum 38) and the NumberInput value did not show, and each sat on a fill with the same layer sum. Raising the label layer made them show. Whether an equal sum always covers was not tested on its own (inference). Give text a larger sum than its fill. The setup is in Building basic components with InvUI.
{measured}(Source: IUC)
Clipping and overlays
- [LAY-22]
clips_children: trueclips children to its own area. Giving a childallow_clipping: falsedraws it outside the ancestor's clipping (a tooltip that goes out of a scroll area).{vanilla, working pack}(Source: VN clips_children 27 uses and allow_clipping 7 uses, BA chapter 5, AP 4.8) - [LAY-23] To darken the surroundings when a tooltip shows, put a very large translucent black image (BA 4000x4000 alpha 0.3, AP 500x500 alpha 0.225) behind the tooltip and give it
allow_clipping: false.{working pack}(Source: BA chapter 5, AP 4.8) - [LAY-24] If you need a background fitted to the text width, grow the parent to
"100%c"/"100%cm"with a measuring label ofalpha: 0, and draw the visible label separately on top.{working pack}(Source: BA chapter 5) - [LAY-68] An omitted
allow_clippinginherits the parent's value (true without a parent). So a control withallow_clipping: falsedraws outside the parent'sclips_children, and its children, unless they set it themselves, drew outside too. The code follows an explicit value, so to clip a descendant again, writeallow_clipping: trueon that descendant (LAY-22).{code (binary), measured}(Source: NB, 2026-11-20 Windows 1.26.65.1)
Grids
- [LAY-25] A grid is made with
grid_dimensions(fixed size) orgrid_dimension_binding(bound size),grid_item_templateandmaximum_grid_items.{vanilla}(Source: VN by property key 37, 79, 117 and 11 uses) - [LAY-26]
grid_fill_directionuses onlyverticalin vanilla. Values likeleft_to_righthave no basis.grid_rescaling_typeuses onlyhorizontal(21) andvertical(1) in vanilla and does not usenoneof the official enum. Of the 3 values ofgrid_fill_directionthe wiki lists (vertical,horizontal,none), onlyverticalhas vanilla evidence.grid_rescaling_type: "vertical"has a crash warning (LAY-32). On a collection grid reading chest slots (grid_dimensions: [3, 2],maximum_grid_items: 6),horizontaldrew only the three cells of the top row andverticaldrew only the first cell and one cell outside the right edge of the grid. It cannot be used for column-first filling.{vanilla, measured}(Source: VN, MJ 4.2-3 and 4, BW-doc, BW-dyn, CPR) - [LAY-29] To place a static child directly in a grid cell, give the child
"grid_position": [column, row](from 0). In agrid_dimensions [4, 2]grid,[3, 0]landed at the top right and[0, 1]at the bottom left (measured, mobile, 2026-11-16). Vanilla also uses it 71 times, and it is also used to overwrite a specific cell of an engine-made grid.{vanilla, measured}(Source: VN, HXC, BW-dyn screenshot) - [LAY-30] For a grid whose count is decided by a binding, give
grid_rescaling_type: "horizontal"and a fixed width and set the count with#maximum_grid_items(ormaximum_grid_items). The column count isfloor(grid width / template width)(160px / 32px = 5 columns, count 15 gives 3 rows). Set the height to"100%c".{measured}(Source: BW-dyn screenshot) - [LAY-31] A grid gives space to hidden (
visiblefalse) items too. This is the opposite of a stack panel (LAY-04), so putting conditional items in a grid leaves empty cells. Make lists that must collapse with a stack panel. In the Cinnabar reconstruction too, grid cell positions are decided by index, so hidden cells take up space. Measured on Windows 1.26.65.1, hiding item 1 of a grid [4,1] left items 2 and 3 at x 40 and 60, and the same items in a horizontal stack panel pulled item 2 to x 20 (claim measurements).{code (source), measured}(Source: BW-dyn "Useful Information", CN, 2026-11-18 Windows 1.26.65.1) - [LAY-32] There is a warning that
grid_rescaling_type: "vertical"can crash the game. Vanilla uses it once (store_item_list_screen.json). When making something new, usehorizontal. In the 2026-11-24 decompilation, vertical rescaling was the formula rows = max(1, floor(height / cell height)), and no path leading to a crash was found.{unverified, vanilla}(Source: BW-dyn, VN, 2026-11-24 Windows 1.26.65.1 decompilation) - [LAY-41] A grid cell ignores its own
anchorandoffset. A template grid fills cells in row-first creation order and does not create cells beyond capacity. In game, the cells of a 100-wide grid withgrid_dimensions: [5, 1]were 20px, and a 12px template stuck to the top left of its cell, leaving 8px between the last item and the right edge. A template size of["100%", "100%"]resolved to the whole grid size, so items stacked one per row downward and overflowed the grid. To spread items evenly, use a fixed template the size of a cell (here[20, 14]) and anchor the item to its center.{code (source), measured}(Source: CN tests D01 and D08, CPR)
Vanilla uses of the [column, row] order of LAY-29 grid_position: inventory_screen.json:1200 (in the 3x3 crafting cells, crafting_input_item_top_mid is [1, 0] and mid_left is [0, 1]), trade_screen.json:327 (the children of the [4, 1] grid are [0, 0] to [3, 0]) and inventory_screen.json:1054 (the children of the armor [1, 4] grid are [0, 0] to [0, 3]).
9-slice and tiles
- [LAY-27] For 9-slice, put a
.jsonof the same name next to the texture file and writenineslice_size([left, top, right, bottom]or one value) andbase_size. Vanilla UI JSON does not usenineslice_sizeas a literal property and uses it once through a binding (#banner_nineslice_sizeto#nineslice_size).{working pack, vanilla}(Source: BA chapter 5, AP 4.9, VN start_screen.json:1639) - [LAY-28] For a repeating background, give the image
"tiled": true.{vanilla, working pack}(Source: VN 44 uses, AP 4.9, BA chapter 5)
Scrolling
- [LAY-42] A scroll view searches for the role controls (viewport, content, track, box, bar panel) breadth-first by name, so their position in the tree is free, but if any one of the four is missing it does not scroll. The box length is ceil(track length x viewport / content). On Windows 1.26.65.1, a scroll with content 5161 and viewport 666 had an 84 px box, matching this formula. Cinnabar keeps the box at 10% of the track or more, but this measurement had a ratio of about 13%, so it did not test that minimum. The Windows 1.26.65.1 code confirms the minimum of 0.1. "If any one of the four is missing it does not scroll" was confirmed in the code only for a missing box (the scroll axis comes from the box's
draggable). The bar panel hides when the content fits.{code (source), code (binary), measured}(Source: CN tests V02, V07 and V06, 2026-11-20 Windows 1.26.65.1, 2026-11-24 Windows 1.26.65.1 decompilation) - [LAY-57] A scroll area covering the whole screen (
common.scrolling_panel) took over touches of that area even when its content was empty. When it was always placed in$screen_content, the vanilla buttons and close button of other forms could not be pressed and only scrolling worked. Create or show a scroll area only in the form that uses it.{measured}(Source: FFR) - [LAY-71] The distance a scroll view moves for one mouse wheel step is a constant independent of the view size. In the code, a scroll view that gets a wheel event clamps new position = current position + (-
scroll_speedx y) to [0, content - viewport] and moves there at once without animation, and the place that creates this event has no term that multiplies by the view size.scroll_speedis stored only once in a static variable of the function, so the value of the first scroll view that gets a wheel event is used for every scroll view after that. y looks like the screen'svertical_scroll_delta(20 if not a number, truncated to an integer), so one step =scroll_speedxvertical_scroll_deltawas inferred. The vanillacommon.scrolling_panelscroll_speedof 15 (ui_common.json:4435) times the default 20 gives 300, which matches the figure "about 300 px" whose measurement conditions are not recorded. It does not match the Windows 1.26.65.1 measurement: in the vanilla chatmessages_scrolling_panel(content 5646 px, viewport 810 px, GUI scale 4) one wheel step moved the content by 56 to 57 client px (about 14 GUI), and one step down was -56. So the 15 x 20 = 300 inference is not supported by this measurement, and the unit of the step value (14 GUI, or 15 with another scale applied) is unknown. After mergingvertical_scroll_delta: 40into the screenchat_screenand reopening it, the step distance was the same, but whether the merge reached the actual screen control was not confirmed (no related log line). The call path from wheel input to this event was not found.{measured, code (binary), inferred}(Source: 2026-11-24 Windows 1.26.65.1 decompilation, VN ui_common.json:4435, 2026-11-25 Windows 1.26.65.1)
Proposed rules
The rules below lack evidence or are not adopted yet. Check the evidence before using them.
- [LAY-44] (proposal) Use only
+and-in size and position expressions. The 551 kinds of vanilla size strings (12,806 uses, 12,712 when counted by element) never have*or/, and Mojang does ratio calculations in a comment and then writes the resulting coefficient ("34.628%x + 2px"instore_common.json:5870, a comment instore_search_screen.json:64). Decimal coefficients (56.25%x,1.1249px) and negative terms ("-50% + 10px") are used. Not checked: whether using*in a size expression ("50% * 2") is ignored or an error.{vanilla}(Source: UIS, bedrock-samples) - [LAY-45] (proposal) Write
anchor_fromandanchor_totogether. Vanilla writes both in 2,985 of 2,997 places (99.6%), and in 106 of those they differ from each other (12 places write only one, 6 each). An omitted side iscenter(LAY-60, measured on Windows 1.26.65.1). Thecenterassumption of JsonForge and Cinnabar matches the game, and the w1zardz editor's assumption thatanchor_toequalsanchor_fromdiffers from the game.{vanilla, code (source), measured}(Source: JF, WZ, CN, bedrock-samples, 2026-11-20 Windows 1.26.65.1) - [LAY-46] (proposal) Do not give a child inside a
"100%c"parent a%size on the same axis. In the vanilla tally this setup appears in 0 of 1,972 places. A comment by the editor (JsonForge) author says the child size decides the parent and the parent size decides the child, making a cycle where nothing is drawn. There is no engine code evidence. On Windows 1.26.65.1, the parent width and the"50%"child width became 0, but a fixed-size sibling (40x10) was still drawn. So "nothing is drawn" does not hold for fixed-size children (claim measurements). Give children of a content panel pixels ordefault.{vanilla, measured, unverified}(Source: JF, bedrock-samples) - [LAY-47] (proposal) The UI pixel size of a screen is not a fixed value. It varies with window size and GUI scale, and visual editors also assume different values (w1zardz 427x240, 520x240, 320x240, JsonForge 384x216). Fixed px are drawn multiplied by an integer scale, and vanilla layouts assume minimum virtual screens of pocket 320x210 and desktop 376x250 (comments at
ui_common.json:6380and6430). If you keep the top-level window within this size it is not cut off at any resolution. Elements attached to the screen edge are placed with the corresponding corner anchor and a small pixel offset. The scale system changed in 1.26.0 (the minimum scale is half the maximum, and handheld devices are DPI based, MS Learn Update1.26.0). Not checked: the scale calculation in 1.26.50.{vanilla, unverified}(Source: NE, ms-learn, WZ, JF) - [LAY-48] (proposal)
common.scrolling_panelcreates only one of thescroll_touch(touch) andscroll_mouse(mouse) subtrees depending on$touch(ui_common.json:4718-4750). The path to the scroll content and the size variables (the_touchpair) differ per input mode, so when pointing inside a scroll with path keys orsource_control_name, consider both paths or pin one side by passing"$touch": trueto the instance (resource_packs_screen.json:2685does the same).{vanilla}(Source: NE, bedrock-samples) - [LAY-49] (proposal)
#anchored_offset_value_x/ypushes in the anchor direction by value times the parent size on a control withuse_anchored_offset: true. It has no effect ifanchor_fromiscenter. To use it on a static control, give a corner or edge anchor. On Windows 1.26.65.1, a static panel in a 100-wide parent moved x by 1000 withtop_leftand 10, and by 10 withbottom_leftand .1.centerand nouse_anchored_offsetdid not move it (claim measurements). A name with the_absolutesuffix had no effect. Not checked: edge anchors.{code (source), measured}(Source: CN, LG, BC, 2026-11-18 Windows 1.26.65.1) - [LAY-50] (proposal) When drawing an engine collection grid (
hotbar_items, etc.) in another shape, copy the vanilla definition while removing thegrid_dimension_bindingproperty itself and fixinggrid_dimensions. Just emptyingbindingsmakes the dimension binding automatically reattach in the Cinnabar model. Conflict C-62.{code (source), unverified, conflict}(Source: CN, LG, bedrock-samples) - Vanilla does not use
wrap_content. Vanilla binds#priority3 times (store_common.json:732, 8239, 8503) with a parent stack set touse_priority: true(LAY-40).{vanilla}
Facts added by community reports (community)
(Source: private research) All are at the report level.
- The type of a text control is
label, nottext. The anchor value isleft_middle, notmiddle_left(LAY-16). - The
"default"size differs by type: a panel 100%, a label the text size, a stack panel["100%","100%c"], a grid["100%c","100%c"](the same as LAY-03 and LAY-38). There is a report that the unitless string"10"gives aDangling numbererror, and Cinnabar reads it as 0 (LAY-34). In the Windows 1.26.65.1 code both hold: it logs and drops the number, giving 0 (2026-11-24 decompilation). - Hidden grid items take up space (LAY-31, Windows 1.26.65.1 measurement). Buttons that will always be hidden (tab, back) go at the end of the collection (COL-35).
- For bottom alignment inside a stack panel, put a
["100%","fill"]panel as the first child so it eats the remaining space. - If you need a moving position, use
use_anchored_offset: trueand#anchored_offset_value_x/y(a ratio against the parent size). Measured on Windows 1.26.65.1, the value on a static panel moved it by a multiple of the parent size and did not move it with acenteranchor (LAY-49). A fixed-size parent and a top-left anchor are the most stable. A view binding that copies a property bag key holding an array to#offsetalso moves the control (LAY-05). #size_binding_x/yis a ratio against the parent (2.5 is 250%), and pixels are_absolute(LAY-10). Measured on Windows 1.26.65.1, .5 gave half the parent width, 2 gave twice, and#size_binding_x_absolute20 gave 20 (measurement record). There is a report that the value must be a number and a wrong value crashes.#anchored_offset_value_x_absolute(top_left, value 10) had no effect on Windows 1.26.65.1, so it is not used.- A bound
#alphaapplies as the float it is: a bound 0.5 on an image with"alpha": "#alpha"was the same translucency as a static 0.5 (LAY-13, Windows 1.26.65.1 measurement). - The grid property name is
grid_dimensions(grid_dimensiongives a type error). Subpixel gaps sometimes appear in windowed mode. The GUI scale can neither be read nor ignored, so use%rather than fixed pixels. - Scrolling: use the variables of
common.scrolling_panel,$scrolling_pane_sizeapplies only when specified insize, and hiding the scrollbar is"$scroll_bar_and_track_size": [0,0](LAY-02, LAY-42). - Phones draw the UI large, so the screen height is small at about 200px. Keep a server form window at fixed pixels and handle overflowing content with inner scrolling (LAY-53, LAY-54).
Conflict verdicts (related to this chapter's rules)
| ID | Topic | Claim and evidence | Verdict |
|---|---|---|---|
| C-43 | A binding expression without # | Measurement discards the whole bindings array, Cinnabar only that one binding | Open: follow BND-05 |
| C-62 | A grid that left grid_dimension_binding | LAY-50 above | Open |
Items that need measurement
- Relayout of a size binding on an open screen (LAY-15). The code recomputes it.- Whether, when two siblings with the same absolute layer overlap, the later sibling is always drawn on top (LAY-19).
- Whether a control with both
inherit_max_sibling_widthandmax_sizegoes past the maximum, and the result when two siblings both turn it on (LAY-69). - Whether a screen with
screen_not_flushable: truecloses when switching to another screen on top of it (LAY-70). - The wheel step of a scroll view with
scroll_speed1 (predicted 20), whether it doubles with a screenvertical_scroll_delta: 40, and whether, with two scroll views on one screen given differentscroll_speed, the value of the one that first got a wheel event is used by the other too (LAY-71). One step of the vanilla chat was about 56.5 client px (about 14 GUI at scale 4), which does not match 15 x 20 = 300.vertical_scroll_delta: 40merged intochat_screenchanged nothing, but whether the merge applied is unknown, so measure again by overriding the whole screen definition or by placing a scroll view directly on a probe screen (Windows 1.26.65.1 measurement, 2026-11-25). - The relation between the window size at which a
[376, 250]panel starts to be cut off and the GUI scale (LAY-47). - Whether the scroll box has a minimum when the viewport is less than 10% of the content (LAY-42).
| id | Source | License | Commit | Accessed |
|---|---|---|---|---|
repo-guide | JSON UI comprehensive guide (this repository) (guide/) | This project's material | 2026-11-13 | |
repo-survey | JSON UI material survey (this repository) (survey/) | This project's material | 2026-11-13 | |
private-research | Private research (-) | - | 2026-11-13 | |
bedrock-wiki | Bedrock Wiki | CC BY 4.0 (docs/licenses/CC-BY-4.0.md in the repository) | 0930b39 | 2026-11-13 |
ms-learn | Minecraft Creator documentation (Microsoft Learn) | CC BY 4.0 (documentation), MIT (code) | a9fd1c0 | 2026-11-13 |
bedrock-samples | Mojang bedrock-samples | Minecraft EULA applies, (c) Mojang AB. All rights reserved | 15701fa9 (guide baseline 46ba6ea) | 2026-11-13 |
cinnabar | Cinnabar (json-ui crate) | PolyForm Noncommercial License 1.0.0 (confirmed in the repository LICENSE). Used only to check behavior and as an implementation reference; the original text is not copied | ceb0fb6 (analysis baseline, clone HEAD df826f5) | 2026-11-13 |
bedrock-core | bedrock-core UI (@bedrock-core/ui) | MIT (confirmed in the repository LICENSE, Copyright 2026 bedrock-core) | aee2bbd (analysis baseline, clone HEAD 51d5cf2) | 2026-11-13 |
advancementpack | AdvancementPack (r4isen1920) | MIT (confirmed in the repository LICENSE, Copyright 2024 r4isen1920) | 0a79929 (analyzed v4.2, researched 2026-10-20) | 2026-11-13 |
mcbejsonuimasterai | mcbejsonuimasterAI | No LICENSE at the repository root (NOTICE.md contains only third-party MIT notices). Facts only, rewritten | 527276c | 2026-11-13 |
netease-docs | NetEase developer documentation, UI chapter (mirror EaseCation/netease-modsdk-wiki) | No LICENSE in the mirror repository, the original is NetEase's work. Facts only, rewritten | 6dd1233 | 2026-11-13 |
repo-tool-analyses | JSON UI tool analysis (this repository) (jsonui-lsp/, jsonui-schemas/, jsonforge/, easyuibuilder/, jsonencryptor/, bedrock-json-ui-editor/) | This project's material | 2026-11-13 | |
jsonforge | JsonForge | MIT (Copyright (c) 2026 JsonForge) | 2874876 | 2026-11-13 |
bedrock-json-ui-editor | bedrock-json-ui-editor (w1zardz) | MIT is stated only in the README, no LICENSE file | 1f18f0d (tools research), 9cb4896 (cases research) | 2026-11-13 |
json-ui-examples | json-ui-examples | MIT (confirmed in the repository LICENSE, Copyright 2025 LeGend) | d4ff500 | 2026-11-13 |