Cross-platform user interface framework for Rust.
This crate provides an HTML-like render API for the backend of a UI. It's built for use as a backend for concoct, but you can bring your own state management tools or build your own framework using this as a backend.
```rust fn app(cx: &mut Context) -> NodeKey { Element::new() .alignitems(AlignItems::Center) .justifycontent(JustifyContent::Center) .child(cx.insert("Hello World!")) .build(cx) }
fn main() { viewbuilder::run(app) } ```
rust
fn app(cx: &mut Context) -> NodeKey {
let mut elem = Element::new();
elem.overflow_y(Overflow::Scroll)
.flex_direction(FlexDirection::Column)
.extend((0..100).map(|count| cx.insert(count.to_string())));
elem.build(cx)
}
rust
fn button(
cx: &mut Context,
label: &'static str,
mut handler: impl FnMut(&mut Context) + 'static,
) -> NodeKey {
Element::new()
.on_click(Box::new(move |cx, _event| handler(cx)))
.background_color(Color4f::new(1., 1., 0., 1.))
.child(cx.insert(label))
.build(cx)
}