Skip to content

feat: reactive ui elements take every layout property, text style and images - #727

Open
makspll wants to merge 4 commits into
agent/reactive-ui-runefrom
agent/reactive-ui-style
Open

makspll wants to merge 4 commits into
agent/reactive-ui-runefrom
agent/reactive-ui-style

Conversation

@makspll

@makspll makspll commented Nov 13, 2026

Copy link
Copy Markdown
Owner

Elements take every layout property of bevy_ui's Node under its own name, plus colours, text style and images, instead of a closed list of 11 properties.

ui.node({
    flex_direction = "row", align_items = "center", justify_content = "space_between",
    padding = { 4, 8 }, margin = { left = 2 }, border = 1, border_color = "#ffffff", border_radius = 6,
    max_width = "50%", overflow = "clip", z_index = 2,
}, {
    ui.image({ image = "icons/sword.png", width = 32, height = 32 }),
    ui.text({ text = "Sword", font_size = 18, color = "#ffcc00" }),
})
  • layout (style.rs): a table of Node fields (style_fields!), each set from a plain value through FromProp, checked by the compiler against the field's type. No reflection or string matching when a property is applied, names are looked up once per element in a map.
    • sizes: a number of pixels, "50%", "10px", "5vw", "5vh", "auto"
    • sides (margin, padding, border): one size, { vertical, horizontal }, { top, right, bottom, left } or { left = .. }
    • enums: the variant's name, "space_between". Listed in the error when wrong
    • nil resets a property to its default
  • border_color, z_index, font_size, color, image (a path, loaded by the asset server; ui.image is a node with one)
  • colours are hex strings or { red, green, blue [, alpha] }
  • ui.describe reports the layout, font size, colours and whether there is an image, for tests

Not included: grid tracks and placement (grid_template_rows etc.), which need their own value syntax.

Stacked on #726. Tested in Lua and Rune.

@semanticdiff-com

semanticdiff-com Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

@makspll
makspll added this pull request to stack #718 November 13, 2026 13:12
@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

ProjectBevy Scripting
Branchagent/reactive-ui-style
Testbedlinux-gha

⚠️ WARNING: Truncated view!

The full continuous benchmarking report exceeds the maximum length allowed on this platform.

⚠️ WARNING: No Threshold found!

Without a Threshold, no Alerts will ever be generated.

🐰 View full continuous benchmarking report in Bencher

init_asset::<Image> in finish replaced ImagePlugin's Assets<Image>, wiping
images added in build (e.g. the tonemapping LUT) and resetting the id
allocator, so later 2D images took the LUT's id and rendering failed.
…ge property

ReactiveUiPlugin no longer initialises Assets<Image> (apps get them from ImagePlugin), the harness has no ImagePlugin.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant