Pure Rust authoring
Build a menu with one prelude, compose children, attach actions and paint a typed surface.
Add the crate
Add QuaUI to the application's Cargo.toml. With a local checkout, use quaui = { path = "../QuaUI/native" }. The revision below pins the interface used by these examples.
TOML[dependencies]quaui = { git = "https://github.com/QuaDevTeam/QuaUI.git", rev = "73f866390244b763fd582287fe916b9740a22791" }
Compose a pause menu
Rustuse quaui::prelude::*;fn pause_menu() -> Result<Surface, LayoutError> { column("menu") .size(240.0, 132.0) .border_box() .padding(16.0) .gap(8.0) .child(text("title", "Paused").height(24.0).font_size(18.0)) .child(button("resume", "Continue").size(160.0, 44.0).on_click("resume")) .compile(240.0, 132.0)}
column lays children out vertically and gap separates adjacent children. Sizes and padding use logical pixels. With border_box the 240 × 132 menu includes its padding. Reserve space for text, as height(24.0) does here, so hosts share the same line box. The arguments to compile describe available layout space.
Paint and handle actions
on_click("resume") creates a ui/intent event with action resume. To carry a parameter, pass Intent::new("save").with_metadata("slot", 2.into()). Give every node a unique ID within the tree and keep it stable across updates.
Once the host implements NativePaintHost, call pause_menu()?.paint(&mut host). Recompile when inputs or dimensions change, then reuse the resulting Surface across frames. Connect a paint host
Run the checked-in example
From the QuaUI repository root, run the example below. It writes the resolved button as JSON for this site's DOM preview. Native hosts can paint the Rust value directly.
Shellcargo run --locked --manifest-path native/Cargo.toml --example continue_button
Compose subtrees using row, column, grid or panel. Use child for one element and children to append an array or iterator. Set Element.layout directly for advanced Taffy styles. Controls, interaction states, provenance and transitions remain available through Element.node. Layout and paint