Skip to content
Refaltor77 edited this page Apr 15, 2026 · 2 revisions

Root

Top-level container for a UI screen. Manages namespace, elements, and animations.

Creation

use refaltor\ui\builders\Root;

$root = Root::create("my_namespace");
// or
$root = Root::create(); // namespace set later via RootBuild

Methods

Elements

$root->addElement($element);          // Add single element
$root->addElements([$el1, $el2]);     // Add multiple

Animations

$root->addAnimation($animation);       // Add single animation
$root->addAnimations([$a1, $a2]);     // Add multiple

Vanilla Modifications

Target vanilla Bedrock UI elements using path syntax. See Modification for all operations.

use refaltor\ui\components\Modification;

// Modify a nested vanilla element
$root->modifyVanillaElement("hud_title_text/title_frame/title", [
    Modification::insertBack(Modification::ARRAY_BINDINGS)
        ->setValue([
            [
                "binding_type" => "view",
                "source_property_name" => "(not (#text = 'hidden'))",
                "target_property_name" => "#visible",
            ]
        ]),
]);

// Add a custom control to a vanilla screen
$root->modifyVanillaElement("hud_screen", [
    Modification::insertBack(Modification::ARRAY_CONTROLS)
        ->setValue([
            ["my_element@my_namespace.my_panel" => []]
        ]),
]);

Configuration

$root->setNamespace("my_namespace");   // Set namespace
$root->setTitleCondition("MY_TITLE");  // Visibility condition

Generation

$root->generateAndSaveJson("ui/my_screen.json"); // Save to file

JSON Output

The Root serializes to:

{
    "namespace": "my_namespace",
    "@my_animation": { "anim_type": "alpha", ... },
    "my_element": { "type": "label", ... }
}

See Also

Clone this wiki locally