Collections and factories
Collections and factories are the mechanism by which JSON UI draws lists whose size is not fixed. They handle data that is known only when the screen is used, such as the number of server form buttons, the number of chest slots and the number of chat lines.
- Collection: the list of items the engine provides. There are form buttons (
form_buttons), modal form rows (custom_form), chest slots (container_items) and chat lines (chat_text_grid), and each item comes with value bindings such as#form_button_textor#item_id_aux. Inside a container that hascollection_name,collection_indexdecides which item to read, and a binding points to which collection to read withbinding_collection_name. - Factory: a mechanism that creates controls at runtime as many as there are items. In the container's
factoryproperty (or a"type": "factory"control) you write what to create (control_name,control_ids), and how many to create is decided by the engine or by the#collection_lengthbinding. - Grid: a container that places the same template control in a lattice. Fix the cell count with
grid_dimensionsor set the count with#maximum_grid_items.
The smallest examples
Example 1. Fixed-index slots (reading only a collection without a factory, COL-06). If the server always sends the same number of buttons, you can hardcode in JSON which item each cell reads.
"tab_slots": { "type": "stack_panel", "orientation": "horizontal",
"collection_name": "form_buttons",
"controls": [
{ "slot0@my.tab_cell": { "collection_index": 0 } },
{ "slot1@my.tab_cell": { "collection_index": 1 } }
] }
Example 2. A factory whose count is set by a binding (the first example of the Bedrock Wiki original below). If you take the number out of the title string Count:3 and put it into #collection_length, 3 controls are created. If it is 0, nothing is created (COL-11).
Example 3. Placing the engine factory again (COL-14). If you place one more factory of the same name, a second UI is created from the same data.
"server_form_factory": { "type": "factory",
"control_ids": { "long_form": "@my.long_form", "custom_form": "@my.custom_form" } }
The Bedrock Wiki explanation (Dynamic Content Generation)
The Bedrock Wiki (bedrock-wiki 0930b39) explains factories and grids this way. The original (CC BY 4.0) is reproduced as is. It is the basic usage of #collection_length, the control_ids array, #maximum_grid_items and grid_position that this document uses. The wiki examples use the HUD title string (#hud_title_text_string) as material.
Excerpt: Dynamic Content Generation - Factories · docs/json-ui/dynamic-content-generation.md · Bedrock Wiki · License CC BY 4.0 (docs/licenses/CC-BY-4.0.md in the repository) · Commit 0930b39Factories
A factory generates UI elements specified in its
control_nameorcontrol_idsproperties.
- Invocation: Many of the vanilla factories are invoked natively by the engine. Alternatively, factories can be invoked manually by overriding the
#collection_lengthproperty.- Data Binding: For the use of
#collection_length, the factory must reside within a collection-supporting container (e.g.,collection_panelorstack_panel). The value can either be anintor astring[]based on the implementation of the factory.Key properties
Property Type Short Description name stringThe unique identifier for the factory. This is critical for factories natively invoked by the engine, though custom factories can use any arbitrary string. control_name stringReference to the control to be generated by the factory control_ids ObjectAn object mapping arbitrary string keys to the references of the controls to be generated. Used when generating multiple distinct controls. Must remain unchanged for natively invoked factories. factory_variables string[]List of variables that should be passed to the controls generated by the factory max_children_size intMaximum number of controls to be generated Usage
Using
control_name:In this case,
#collection_lengthmust be overridden with anintvalue. This is the number of elements that will be generated.{"hud_apple": {"type": "image","texture": "textures/items/apple","size": [32, 32]},"apple_factory": {"type": "stack_panel","size": [ "100%cm", "100%c" ],"factory": { // Defined in a stack_panel (Supports collection)"name": "hud_apple_factory","control_name": "hud.hud_apple" // Reference to hud_apple},"bindings": [{"binding_name": "#hud_title_text_string","binding_name_override": "#count"},{"binding_type": "view","source_property_name": "(#count - 'Count:' + 0)", // Gets the int value"target_property_name": "#collection_length" // Overriding #collection_length}]}}Here, an integer value is sent through the title as
Count:{value}that indicates the number of elements to generate. The bindings listed above first fetch the title string and store it in#count. Then,#count - 'Count:'gets theintvalue and#collection_lengthis overridden with this value. Note:+ 0sets a default value of 0 if the string is empty.Expected result: For title:
Count:3Using
control_ids:In this case,
#collection_lengthmust be overridden with an array of strings. The strings are the keys defined incontrol_ids. There's not much freedom with this approach as there is no way to manipulate arrays in JSON UI. Instead, we can pre-define some arrays within theproperty_bagand choose from them. The elements will be generated in the order specified in the array.{"hud_apple": {"type": "image","texture": "textures/items/apple","size": [32, 32]},"hud_label": {"type": "label","text": "Apple!","shadow": true},"apple_factory": {"type": "stack_panel","size": [ "100%cm", "100%c" ],"factory": {"name": "hud_apple_factory","control_ids": {"apple": "hud.hud_apple", // An arbitrary name mapped to the reference of a control"label": "hud.hud_label"}},"property_bag": {// Some pre-defined arrays"#list1": [ "apple", "label" ],"#list2": [ "label", "apple" ]},"bindings": [{"binding_name": "#hud_title_text_string","binding_name_override": "#choice"},{"binding_type": "view","source_property_name": "('#list' + #choice)", // Constructing key name"target_property_name": "#collection_length"}]}}Here, we have defined two controls in
control_idsand two arrangements of these controls as#list1and#list2. In the bindings, we fetch the title string and store it in#choice, which is an integer representing the list to be selected. Then using('#list' + #choice), we construct the name of the list and that list is then overridden to#collection_length.Expected result: For title:
1and2respectively
Excerpt: Dynamic Content Generation - Factory (Extra) · docs/json-ui/dynamic-content-generation.md · Bedrock Wiki · License CC BY 4.0 (docs/licenses/CC-BY-4.0.md in the repository) · Commit 0930b39Factory (Extra):
You can define factories directly using
"type": "factory"as well. These factories are always invoked natively by the engine. However, it is possible to define these factories in the ways discussed above we can also modify the control references to generate custom elements instead.{"main_screen_content": { // Vanilla code from server_form.json"type": "panel","size": [0, 0],"controls": [{"server_form_factory": { // Name of control here acts as the factory name and thus should remain unchanged"type": "factory","control_ids": {"long_form": "@server_form.long_form","custom_form": "@server_form.custom_form"}}}]}}
Excerpt: Dynamic Content Generation - Grids · docs/json-ui/dynamic-content-generation.md · Bedrock Wiki · License CC BY 4.0 (docs/licenses/CC-BY-4.0.md in the repository) · Commit 0930b39Grids
Grids generate and arrange UI elements in a grid layout. The elements are generated from a template control specified in its
grid_item_templateproperty. We can either generate a fixed number of elements by defininggrid_dimensionsor a variable number by overriding its#maximum_grid_itemsbinding ormaximum_grid_itemsproperty.Key properties
dangerTry not to use
verticalas the value ofgrid_rescaling_type. It may crash your game.Usage
infoGrids typically have a default size of
["100%c", "100%c"]. It is ideal to keep the height dynamic (100%c). If a fixed height is applied, generated elements may overlap if the height is too small, or have unintended gaps if the height is too large.Using
grid_dimensions:It is recommended not to override the
sizeproperty in this case, as some elements can go outside the grid bounds and mess up the layout.{"hud_apple": {"type": "image","texture": "textures/items/apple","size": [32, 32]},"apple_grid": {"type": "grid","grid_dimensions": [3, 3],"grid_item_template": "hud.hud_apple"}}Expected result:
Overriding
#maximum_grid_items:For this to work properly, you have to modify the width of the grid. This is because the number of columns in this case will be
floor( width of grid / width of template control ). Moreover, we need to setgrid_rescaling_typetohorizontal. Then we have to override#maximum_grid_itemsthrough bindings, or alternatively, define themaximum_grid_itemsproperty.{"hud_apple": {"type": "image","texture": "textures/items/apple","size": [32, 32]},"apple_grid": {"type": "grid","size": [160, "100%c"], // floor(160 / 32) = 5; Meaning the grid will have 5 columns"grid_item_template": "hud.hud_apple","grid_rescaling_type": "horizontal","bindings": [{"binding_name": "#hud_title_text_string","binding_name_override": "#count"},{"binding_type": "view","source_property_name": "(#count - 'Count:' + 0)", // Gets the int value"target_property_name": "#maximum_grid_items" // Overriding #maximum_grid_items}]}}Here, an integer value is sent through the title as
Count:{value}that indicates the number of elements to generate. The bindings listed above first fetch the title string and store it in#count. Then,#count - 'Count:'gets theintvalue and#maximum_grid_itemsis overridden with this value.Expected result: For title:
Count:15Grid Position
There might be situations where you'd want to manually add controls to the grid instead of generating them from a template. With the
grid_positionproperty you can place your control anywhere on the grid.Usage
Let's say we have a grid with 2 columns and 2 rows and we want to place our controls in this way-
The format
[row, column]indicates the placement within the grid, where the first integer is the row index and the second integer is the column index. The following integer is the index it takes inside the grid for a defined collection.The code:
{"hud_apple": {"type": "image","texture": "textures/items/apple","size": [32, 32]},"apple_grid": {"type": "grid","size": ["100%c", "100%c"], // Define it explicitly to avoid layout issues"grid_dimensions": [2, 2],"controls": [{"apple_1@hud.hud_apple": {"grid_position": [0, 0]}},{"apple_2@hud.hud_apple": {"grid_position": [1, 1]}}]}}Expected result:
Useful Information
- When used with a collection, Factories and Grids automatically index generated elements.
- Generated elements can access outside bindings via
source_control_name, but outside elements cannot access bindings from generated elements.- Invisible elements inside a Grid still occupy physical space, which can leave unintentional gaps in your UI.
- In Grids, animations linked with the
nextproperty can appear bugged. After the first animation, the duration divides among the grid elements, causing subsequent animations to speed up. (flip_bookanimations are the only exception).
The differences between this original and this project's measurements are as follows.
- The wiki uses
(#count - 'Count:' + 0). The reason the result becomes a number is EXP-26 (the type of an intermediate result of an expression is decided again by its appearance). To be sure, write((#count - 'Count:') - 0). - The wiki builds a factory with only
stack_panel+factorywithoutcollection_name. The same approach worked in measurement (COL-24). - The wiki says controls inside a factory or grid read outside bindings with
source_control_namebut the outside cannot read the inside (the same conclusion as BND-19). - The wiki's "bug where animations chained with
nextinside a grid speed up" and the warning thatgrid_rescaling_type: verticalcan freeze the game were moved to ANI-18 (unverified). - Grid property summary:
grid_dimensions([column, row]),grid_dimension_binding(the binding name for the cell count, hardcoded names only),grid_item_template(a reference to the cell definition),grid_rescaling_type(none,horizontal,vertical),maximum_grid_items(maximum count, binding#maximum_grid_items),grid_position([row, column]). The column count isfloor(grid width / template width).
The way to read the list data the engine provides (form buttons, modal rows, chest slots, chat lines, dialogue buttons) is a collection, and the mechanism that creates controls as many as the items of that list is a factory. The full factory summary is in Factory synthesis.
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. NB was read by analyzing the native library of the Android 1.26.52.3 client, and its level is code. 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.
Collection addressing
- [COL-01]
collection_nameis used onstack_panel,gridandcollection_panel. Using it onpanelorimagegives anUnknown property [collection_name]error.{measured, vanilla}(Source: BC-facts, BC-S9, BC-S11, VN grid 66, stack_panel 25, collection_panel store_common.json:750, MJ chapter 9) - [COL-02]
collection_indexis received only at the instantiation point (an item inside the parent'scontrols). Written in a top-level definition it is rejected, and on animageit is rejected anywhere. On alabelit is read: on Windows 1.26.65.1, alabelwithcollection_indexdirectly under acollection_namestack_panelread its value (b1) (measurement record). The engine readscollection_indexonly on direct children of a parent that has a collection name (COL-44).{measured, code (binary)}(Source: BC-facts, NB-07, BC 4.1-(4)) - [COL-03] The index is inherited down the subtree from the point where it was applied. So the pattern of writing the definition once and giving N references only a different index and offset holds. Bindings that read a collection each specify the collection with
binding_collection_name.{measured}(Source: BC-facts) - [COL-04] A server form button counts a press toward that entry only if the button itself has
{ "binding_type": "collection_details", "binding_collection_name": "form_buttons" }. If only an ancestor gives the index, it can be pressed but the script receivescanceled, which cannot be told from Esc, and there is no log (when the user closes it,reason=UserClosedarrives, but whether the reason for a missing binding can be told apart was not confirmed). Vanilla form buttons have the same structure.{measured, vanilla}(Source: BC-S1, BC-facts, VN server_form.json:211-225) - [COL-05] A collection binding with no index host at all reads item 0. This property was used to hide the vanilla chest label with the slot 0 item.
{measured}(Source: BC-facts) - [COL-06] You can make fixed-index slots without a factory: put children with hardcoded
collection_indexin a stack that hascollection_name. The script always sends the same number of entries (including empty values) to fix the index.{working pack, code (source)}(Source: BA chapter 5 tab 28 slots, BC 4.1-(3))
"tab_slots": { "type": "stack_panel", "orientation": "horizontal",
"collection_name": "form_buttons",
"controls": [
{ "slot0@my.tab_cell": { "collection_index": 1 } },
{ "slot1@my.tab_cell": { "collection_index": 2 } } ] }
- [COL-26] Factories and grids used with collections automatically attach an index to the controls they create.
{unverified}(Source: BW-dyn) - [COL-38]
collection_indextook effect only on a direct child of astack_panelthat hascollection_name. When that place was apanel,Unknown property [collection_index]and[collection_name]were printed in the content log and it was empty (the same conclusion as COL-01 and COL-02, and the same for the chest screencontainer_items).{measured}(Source: DF) - [COL-44] When creating a control, if the parent has a collection component with a collection name, that control automatically becomes a collection item.
collection_indexis read only then (default -1) and fixes the index. Socollection_indexis meaningful only on a direct child of a collection parent (the same conclusion as COL-02 and COL-38). For a control that is a direct child but must not become an item (a decorative panel, etc.), give"ignoreCollectionItem": true.{code (binary)}(Source: NB-07) - [COL-50] For a 2D layout of fixed
collection_indexcells, put horizontalstack_panelrows that havecollection_nameinside a verticalstack_panel, and put the cells as direct children of the rows (COL-38, LAY-56). If the cell parent was apanel, every cell drew the same button (index 0) even with different indices per cell, and adding acollection_detailsbinding ortoggle_grid_collection_nameto the cells did not change it.{measured}(Source: FFR)
Reading values from a collection
| Collection | Item value bindings (examples) | Source |
|---|---|---|
form_buttons (action form) | #form_button_text, #form_button_texture, #form_button_texture_file_system | VN server_form.json, BC, BA |
custom_form (modal form) | #custom_toggle_state, #custom_slider_steps, #custom_slider_value, #custom_dropdown_length … | VN, BC 4.2 |
custom_dropdown, custom_multiselect | #custom_radio_toggled, #custom_radio_text, #dropdown_option_text, #custom_multiselect_toggled | VN server_form.json:485 and 582, MJ 4.1 |
container_items (chest) | #item_id_aux, #inventory_stack_count, #item_durability_current_amount, #item_durability_total_amount, #item_custom_color | BC-facts, BC-S14 |
student_buttons_collection (NPC dialogue) | #student_button_text (+ binding_collection_prefix: "student_buttons") | VN npc_interact_screen.json:1180, AP 4.3 |
chat_text_grid (chat) | #chat_text | AP-samples hud_screen.json |
- [COL-07] The durability of chest slots (
#item_durability_current_amount,#item_durability_total_amount) can be read in ordinary controls and compared and divided if read with acollection_details+collectionbinding pair.#item_durability_current_amountis the remaining durability (((0 + value) > 100)was true for an iron sword with 100 damage). The value is a float, so comparisons work but concatenating it to a string gives nothing (EXP-22).('D ' + (0 + value))and('D ' + (value * 1))gave only'D 'whatever the binding setup. To show it as text, split it into ranges with a comparison chain.{measured, inferred}(Source: BC-S14, BC-S6, BC 6.8-7, CPR) - [COL-30] The engine writes the grid cell count as
#grid_number_size, the factory creation count as#collection_number_sizeand the collection size as#collection_total_itemsinto the bag. A view binding can read them for use such as an "empty" indicator.{code (source)}(Source: CN tests B55 and B41)
Factories
A factory has two forms.
// (a) A factory control: type is factory. The entry point of vanilla server_form
"server_form_factory": { "type": "factory",
"control_ids": { "long_form": "@server_form.long_form", "custom_form": "@server_form.custom_form" } },
// (b) The factory property of a container: a stack/panel/collection_panel creates the cells
"long_form_dynamic_buttons_panel": { "type": "stack_panel",
"factory": { "name": "buttons",
"control_ids": { "button": "server_form.dynamic_button", "label": "@server_form.dynamic_label",
"header": "@server_form.dynamic_header", "divider": "@settings_common.option_group_section_divider" } },
"collection_name": "form_buttons",
"bindings": [ { "binding_name": "#form_button_contents", "binding_name_override": "#collection_length" } ] }
- [COL-08] A factory is either (a) a
"type": "factory"control (36 uses in vanilla, not in the official enum) or (b) the"factory": { … }property of a container. The keys of thefactoryobject arename,control_name(one kind) orcontrol_ids(per kind),max_children_sizeandfactory_variables.{vanilla}(Source: VN server_form.json:25 and 126, VN factory key tally) - [COL-09] The keys of
control_idsare data kinds the engine decides, and the values are"@ns.definition"(197 uses in vanilla),"instancename@ns.definition"(36 uses) and"ns.definition"(5 uses, for example server_form.json:128). The action form rows arebutton,label,headeranddivider, the modal rows arelabel,toggle,slider,step_slider,dropdown,input,header,dividerandmultiselect, the HUD ones arehud_title_textandhud_actionbar_text, and chat's ischat_item.{vanilla}(Source: VN server_form.json:126 and 283, hud_screen.json:3406, 3417 and 1040) - [COL-10]
visibleonly stops drawing and does not stop creation and layout. A screen attached under the server form is fully created and laid out every time any form is opened, even if hidden withvisible(measured with 5,546 controls repositioned). A component inside it that validates its state at creation, such as a slider, raises an assert even when hidden. The control's ownbinding_condition: "visible"also does not stop evaluation when an ancestor is hidden.{measured}(Source: BC-S8, BW-best) - [COL-11] If you bind
#collection_length, the factory creates only that many cells. If 0, nothing is created. A computed length like((#mode = 'on') * 1)becomes a gate that "creates only the one screen needed".{measured, vanilla}(Source: BC-S11, VN server_form.json:138 and 300) - [COL-12] A comparison of ways to stop creation.
{measured, vanilla}(Source: BC-S8, BC-S11, VN)
| Method | When evaluated | Condition material | Cost |
|---|---|---|---|
ignored | Once at control creation | $variable only | Not created |
Factory #collection_length | Runtime, binding | #binding expression | Not created if 0 |
visible | Every frame | #binding expression | Creation and layout cost stay |
- [COL-13] A row type factory creates a cell for every matching row. If there are three slider rows, three slider cells are created per socket. Cells that are not their own row are pushed off screen with
#anchored_offset_value_y(((not #mine) * 1000)).{measured}(Source: BC-S9) - [COL-14] If you declare an engine factory of the same name once more at another location, a second UI is created from the same data. All three packs use this method:
server_form_factory(BC, BA),hud_title_text_factory(BA, AP) andchat_item_factory(AP).{working pack, code (source)}(Source: BC 4.1-(1), BA chapters 2 and 6, AP 4.1 and 4.5, BW-form, BW-intro) - [COL-15]
factory_variables: ["$a", "$b"]passes the factory host's variables to the created controls. The engine looks up each name in the scope that declared the factory and passes its value (COL-41). Vanilla uses it 37 times (store, pdp, marketplace_sdl, realms_settings, toast_screen, etc.), but none of this project's sources measured it in game.{vanilla, code (binary)}(Source: VN store_common.json and others 37 uses, NB-04) - [COL-16]
max_children_sizeis the maximum number a factory creates (vanilla HUD chat 50, AP toast 12). A second factory sharing the same data uses up the limit even on invisible items.{vanilla, working pack, inferred}(Source: VN hud_screen.json:1041, AP 4.5) - [COL-17] Controls created by an engine factory sometimes receive data as variables. The vanilla actionbar label uses
"text": "$actionbar_text", and AP reads$title_textin a control created byhud_title_text_factoryand decides withignored. A variable is decided once at creation, so when the value changes the factory recreates the control.{vanilla, working pack}(Source: VN hud_screen.json:2158, AP 4.1, BW-intro) - [COL-18] If the cells a factory creates are big, opening the screen is slow. BA had hundreds of controls in one node, so opening took several seconds when all tabs were sent, and it was changed to send only the selected tab's node. Reducing cell size x count comes first.
{working pack}(Source: BA chapter 4) - [COL-22] If you give a factory with
control_idsa string array (the list of keys of thatcontrol_ids) through#collection_length, it creates controls of those kinds in array order. An expression cannot build an array, so put the array inproperty_bagin advance ("#list1": ["apple", "label"]) and pick it by assembling the name with('#list' + #choice). Acontrol_namefactory takes an integer. With#collection_lengthonly inproperty_bagand no binding, nothing was created, array or integer, and binding a global that does not exist to#collection_lengthgave the same (measurement record).{measured}(Source: BW-dyn, 2 screenshots, 2026-11-19 Windows 1.26.65.1) - [COL-23] A
'#name'string made by an expression is read as the value of that name in the same control'sproperty_bag(dictionary lookup). COL-22 and bedrock-core's screen routing (HOST-06('#route_' + #title_text)) are the same mechanism. Principle: if the result of a parenthesized group is a#namestring, it is replaced by the value in that control's bag (EXP-35).{measured, code (source)}(Source: BW-dyn screenshot, BC 4.1-(2), CN-run) - [COL-24] A factory driven directly by
#collection_lengthgoes in thefactoryproperty of a container that supports collections (stack_panel,collection_panel). The wiki example worked with onlystack_panel+factorywithoutcollection_name.{measured}(Source: BW-dyn screenshot) - [COL-25] For a
"type": "factory"control, the control name is the factory name (server_form_factory). Make a second factory with"type": "panel"+"factory": { "name": "server_form_factory", … }and name the control so it does not collide with the original or siblings. The engine does not read a factory name separately from atype: factorycontrol, and other types readnameof thefactoryobject (COL-42).{code (binary), vanilla}(Source: NB-05, VN server_form.json, BW-form (beware of name collision)) - [COL-42] If it is
"type": "factory"and that control directly hascontrol_nameorcontrol_ids, the factory name is not read separately (the control name is the factory name, COL-25). Other types create a factory only when a"factory": { … }object exists, and if itsnameis empty it leavesThe factory name should not be empty!.{code (binary)}(Source: NB-05) - [COL-45] Factory resolution path: if it is
"type": "factory"and directly hascontrol_nameorcontrol_ids, it resolves without a name, and otherwise, regardless of type, it resolves only whenfactoryis an object and readsname(you may also write afactoryobject on atype: factory). Only one factory attaches to one control.control_namebuilds the prototype right away with the declaring control's variable scope at resolution, andcontrol_idsstores only the kind and definition string (the COL-29 difference).max_children_sizeis 0 if omitted.{code (binary)}(Source: NB-13) - [COL-27]
#collection_lengthaccepts an integer, a boolean (1/0) and an array of role names. A literal numeric length creates that many only in acontrol_nametemplate factory. A role name not in the factory creates nothing. The engine also gives a role name array (["tag", …]) as a length value on the store screen (COL-46).{code (source), code (binary)}(Source: NB-14 (role name array), CN tests N12 and B41 (the rest)) - [COL-28] If
control_nameexists,control_idsis not read. Do not put both together.max_children_size: 0is unlimited.{code (source), code (binary)}(Source: NB-06 (control_namefirst), CN (max_children_size: 0)) - [COL-43] A factory reads
control_namefirst and readscontrol_idsonly when it is empty (COL-28).insert_locationinserts at the front only when the value is exactly"front"and anything else is back (defaultback).{code (binary)}(Source: NB-06) - [COL-29] Cells of a
control_nametemplate and ofgrid_item_templatesee the$variablesof where the factory was declared. Controls made bycontrol_idssee only their own variables and those passed withfactory_variables. The engine builds thecontrol_nameprototype in the declaring scope when resolving the factory (COL-45).{code (source), code (binary)}(Source: NB-13 (control_nameprototype), CN, COL-15 reinforcement) - [COL-41]
factory_variablesis read only when it is an array and silently ignored if not. If an item is not a string, it leaves the errorfactory_variables should all be strings of json variables created higher up the tree.. Each name is looked up in the scope of the control that declared the factory, and its value is stored in the factory and received by the created controls (the same as the inference in COL-15).{code (binary)}(Source: NB-04) - [COL-36] Factory and grid lengths followed the value even when computed with an expression of
#form_button_length. On Windows 1.26.65.1, astack_panelwithcollection_name: "form_buttons"and afactory(control_name) was placed inside a factory-created router window, and 6 buttons were sent. Withalwayson the length binding,#form_button_contentsmade 6,#form_button_lengthmade 6,(#form_button_length - 1)made 5, and((#form_button_length * 0) + 1)made 1. Withbinding_condition: "visible"on the length binding, every factory made 0, even the vanilla form#form_button_contents. In a grid withgrid_rescaling_type: "horizontal",#maximum_grid_itemsfrom#form_button_length(always_when_visible) gave 6 cells and from(#form_button_length - 1)gave 5 cells (measurement log). The DF measurement (Windows 1.26.52), taken in another structure, recorded that an expression (* 1,* (marker match)) made the factory create no buttons and the grid become the expression itself; this structure did not reproduce it. When a factory comes out empty, check the length binding's condition first.{measured}(Source: DF, 2026-11-18 Windows 1.26.65.1) - [COL-39] Dictionary lookup routing (HOST-06) worked: with
"property_bag": { "#df_layout_1": [ "on" ], "#df_layout_0": [] }on astack_panel,"factory": { "control_ids": { "on": "…" } }, and#collection_lengthbound from(('#df_layout_' + (condition * 1))), the layout was created only when the condition matched. There was no freeze or exit (a different result from DBG-19).('#if_' + boolean)also became'#if_true'or'#if_false'and found theproperty_bagkey (measurement record).{measured}(Source: DF, 2026-11-19 Windows 1.26.65.1) - [COL-46]
tags_factory_first_hidden_child_index,languages_factory_first_hidden_child_indexand<prefix>_first_hidden_child_index, which vanilla does not have, are exclusive to the store detail screen description component. This integer in the property bag decides from which tag or language to hide or push to the next row, and an array repeating"tag"or"language"that many times is given as the length binding value. It is not a general factory feature, so it is not used in server form or HUD factories. Who uses this value was not checked.{code (binary)}(Source: NB-14) - [COL-37] With a stack that walks whole buttons per row (a 48-cell grid + a material row), the screen took 4~5 seconds to open, and switching to a fixed layout that reads only one button per cell with
collection_index(COL-06) made it about 1 second. Also put only one button per cell (having both a pressable one and a non-pressable one doubles the controls).{measured}(Source: DF) - [COL-49] When drawing buttons in a 2-column grid (cell height 30px), it was fine up to 2000 (about 30000px), and at 3000 (about 45000px) and above only the scroll range was long and the cells were drawn overlapping within the top 200px or so. The cause was not confirmed. Drawing the same count as a one-column vertical stack factory of length
#form_button_contentsdrew but lagged heavily.{measured}(Source: FFR)
Form rows and response numbers
- [COL-19] The action form collection (
form_buttons) in 1.26.50 vanilla receives not onlybuttonbut alsolabel,headeranddividerrows. Theselectionof the response counts only buttons, so mixing inlabel()shifts the collection index and theselectionnumber. When using it as a data channel, send every entry withbutton()and make cells that must not be pressable by removing the button mapping.{vanilla, code (source)}(Source: VN server_form.json:126-134, BC 4.1-(3)) - [COL-20] The
custom_formrows of a modal form andformValuesline up 1:1. Alabel()is also a row andnullarrives in its place in the response.{measured}(Source: BC-S3) - [COL-21] A
multiselectrow was added to thecustom_formfactory in 1.26.50 vanilla, but the public Script API (@minecraft/server-ui2.2.0~2.5.0-beta, bothModalFormDataandCustomForm) has no method that sends this row. A server that sends the form JSON directly can use it (HOST-46).{vanilla, code (source), measured}(Source: VN server_form.json:294, MJ 4.1, MS) - [COL-34] The client held the action form's
#form_button_lengthat the button count of the largest form seen so far (debug label 93, still 93 after reconnecting, unchanged withalways_when_visibletoo). If you set the grid size from this value, empty cells continue in a smaller form. Send the cell count separately through a data channel such as the body (EXP-45). It did not reproduce on Windows 1.26.65.1 (2026-11-19): a 4-button form opened after a 30-button form gave4(measurement record).{measured, conflict}(Source: DF, 2026-11-19 Windows 1.26.65.1) - [COL-35] A wrapping grid gives cells to hidden buttons too. Send marker buttons such as tab, back and page after the cell buttons (if placed before, the cells start shifted), and put only the number of cell buttons in the grid size (putting more made one extra empty row and the window scrolled a few pixels).
{measured}(Source: DF)
Form data inside windows created by a factory
- [COL-40] Fixed
collection_indexcells inside a layout created by our factory also receive action form data, but they need a binding condition. On Windows 1.26.65.1, the fixed cells in the window of a router inserted withinsert_backintomain_screen_contentofserver_formwere empty on first open with the default condition and filled from the first open withalwayson both bindings (measurement record, COL-47).panel+factorycreated nothing. In one setup (DF) only grid (grid+collection_name) cells received data, and fixed cells and an inner#form_button_contentsfactory stayed empty even withalways; the router position in that setup was not checked. With a 1x1 grid lazy root in the same router window (grid[1,1],#maximum_grid_itemsset to the button count withonceand to a title check expression withvisible) and fixedcollection_index0, 4, 5 on astack_panelinside its cell, the cells filled from the first open even with the default binding condition (same on a second open, record).{measured}(Source: DF, 2026-11-19 Windows 1.26.65.1) - [COL-47] Inside a window created by the dictionary lookup router (HOST-06) placed in
$screen_contentofthird_party_server_screen, the fixedcollection_indexcells, the radio toggle cells and a stack factory of length#form_button_contentsall received action form data. But if the cells' collection,collection_detailsand body bindings had the default condition, they were empty on first open and filled after switching a tab once, and when all were set tobinding_condition: "always"they were filled as soon as it opened. On Windows 1.26.65.1, fixed cells measured with a router inserted withinsert_backintomain_screen_contentofserver_formbehaved the same: empty on first open with the default condition (both when opened from the HUD and when coming from a menu form), and filled from the first open withalwayson both bindings (measurement record). When the fixed cells sit inside the cell of a 1x1 grid lazy root (grid[1,1],#maximum_grid_itemsset to the button count withonceand to a title check expression withvisible) instead of directly in the routercollection_panel, they filled from the first open even with the default condition (2026-11-19 Windows 1.26.65.1, record).{measured}(Source: FFR) - [COL-48] A factory placed inside a cell created by a factory created nothing at first if
#title_textand the length binding had the default condition. Giving those two bindingsalwaysmade it created as soon as it opened. Changing the inside to a grid also worked. Having a size animation recalculate the layout, or reading the length from an outside data source, had no effect.{measured}(Source: FFR)
Example: the smallest collection grid
A minimal setup that draws the action form buttons the server sent in a 2-column grid. This example worked in game with the code below as is {measured} (example measurement record, 2026-11-27 Windows 1.26.65). It is jup.json and server_form.json of Grid button list trimmed down.
Rules it relies on: COL-01, COL-02, COL-10, COL-47. The order and conditions follow Filling the first frame without always (BND-37).
The complete add-ons measured in game can be downloaded from two documents. Grid button list is a list with a scroll area, icons and progress bars, and Filling the first frame without always is a comparison add-on with two lists whose binding conditions differ.
RP/
manifest.json
ui/
_ui_defs.json
mygrid.json
server_form.json
manifest.json needs only a single resources module, the same as in the example in section 10 of HUD and title channels. _ui_defs.json registers only the new file. server_form.json is at the same path as vanilla, so it is not registered (FILE-01).
{
"ui_defs": [
"ui/mygrid.json"
]
}
ui/mygrid.json defines the cell, the grid, the window and the router.
{
"namespace": "mygrid",
"cell_face": {
"type": "panel",
"size": [ "100%", "100%" ],
"$bg_texture|default": "textures/ui/button_borderless_light",
"controls": [
{ "bg": { "type": "image", "texture": "$bg_texture", "size": [ "100% - 2px", "100% - 2px" ] } },
{
"name": {
"type": "label",
"layer": 3,
"size": [ 90, 10 ],
"offset": [ 6, 10 ],
"anchor_from": "top_left",
"anchor_to": "top_left",
"color": [ 0.1, 0.1, 0.1 ],
"localize": false,
"text": "#text",
"bindings": [
{ "binding_type": "collection", "binding_collection_name": "form_buttons", "binding_name": "#form_button_text" },
{ "binding_type": "view", "source_property_name": "('%.12s' * #form_button_text)", "target_property_name": "#text" }
]
}
}
]
},
"cell@common.button": {
"size": [ 100, 30 ],
"$focus_enabled": false,
"$pressed_button_name": "button.form_button_click",
"bindings": [
{ "binding_type": "collection_details", "binding_collection_name": "form_buttons", "binding_condition": "always" }
],
"controls": [
{ "default@mygrid.cell_face": {} },
{ "hover@mygrid.cell_face": { "$bg_texture": "textures/ui/button_borderless_lighthover" } },
{ "pressed@mygrid.cell_face": { "$bg_texture": "textures/ui/button_borderless_lightpressed" } }
]
},
"button_grid": {
"type": "grid",
"size": [ 200, "100%c" ],
"offset": [ 0, 20 ],
"anchor_from": "top_middle",
"anchor_to": "top_middle",
"grid_rescaling_type": "horizontal",
"grid_item_template": "mygrid.cell",
"collection_name": "form_buttons",
"bindings": [
{ "binding_name": "#form_button_length", "binding_name_override": "#maximum_grid_items", "binding_condition": "always" }
]
},
"list_window": {
"type": "image",
"texture": "textures/ui/dialog_background_opaque",
"size": [ 224, 140 ],
"layer": 60,
"controls": [
{ "close@common.close_button": {} },
{ "grid@mygrid.button_grid": {} }
]
},
"screen_router": {
"type": "collection_panel",
"size": [ "100%", "100%" ],
"factory": {
"name": "mygrid_screen",
"control_ids": { "g": "@mygrid.list_window" }
},
"property_bag": { "#§b§wmg:G": [ "g" ] },
"bindings": [
{ "binding_name": "#title_text" },
{ "binding_type": "view", "source_property_name": "('#' + ('%.10s' * #title_text))", "target_property_name": "#collection_length" }
]
}
}
ui/server_form.json inserts the router next to server_form_factory.
{
"namespace": "server_form",
"main_screen_content": {
"size": [ "100%", "100%" ],
"modifications": [
{
"array_name": "controls",
"operation": "insert_back",
"value": [ { "mygrid_router@mygrid.screen_router": {} } ]
}
]
}
}
The server sends an action form whose title is §b§wmg:G with a few buttons. With 5 buttons the cells lay in 2 columns, each cell showed the first 12 bytes of its button text, and pressing the fourth cell gave the server selection 3. A form with another title made no grid window {measured}. The vanilla form stays drawn behind.
How the rules map to the code:
collection_nameis on thegrid. On apanelorimageit gives anUnknown propertyerror (COL-01).- This example does not use
collection_index. Whether a grid gives cells indexes automatically is{unverified}(COL-26), andcollection_index, which fixes an index, is read only on a direct child of a parent that hascollection_name(COL-02, COL-38, COL-44). If you need fixed cells, wrap the label in a panel and give the index to the panel reference (COL-02). visibleonly stops drawing and does not stop creation and layout (COL-10), so for server forms other than this one, the router makes zero windows. Looking upproperty_bagwith the first 10 bytes of the title and putting the result in#collection_lengthis the mechanism of HOST-06, COL-22 and COL-23.- Inside the window the router creates, the grid length and the cell's
collection_detailsusebinding_condition: "always". With the default condition they were empty on first open (COL-47, COL-48). The label inside the cell uses the order collection binding then view binding, with no condition (BND-37).
Left out because the wiki has no basis: a scroll area (with many buttons the grid overflows the window, and the scrolling setup is in the complete add-ons), a binding that hides the vanilla form for this title (it is in the add-on's server_form.json), and the window and cell sizes. A 2-column grid drew cells overlapping at 3000 buttons and more (COL-49).
| id | Source | License | Commit | Accessed |
|---|---|---|---|---|
repo-guide | JSON UI comprehensive guide (this repository) (guide/) | This project's material | 2026-11-13 | |
bedrock-samples | Mojang bedrock-samples | Minecraft EULA applies, (c) Mojang AB. All rights reserved | 15701fa9 (guide baseline 46ba6ea) | 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 |
private-research | Private research (-) | - | 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 |
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 |
starlibv2 | StarLibV2 | GPL-3.0 (confirmed in the repository LICENSE) | 6bf7875 | 2026-11-13 |