viewbuilder 0.6.0-alpha.1

Cross-platform UI framework
docs.rs failed to build viewbuilder-0.6.0-alpha.1
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build: viewbuilder-0.10.0-alpha.5

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.

Features

  • Cross-platform with desktop and mobile support
  • Event handling with an HTML-like API
  • CSS flexbox and grid layout with taffy
  • Accessibility with accesskit
  • High performance rendering with rust-skia

Getting started

Instatllation is simple with:

cargo add viewbuilder

If you encounter errors, please check the instructions for building rust-skia.

Examples

Hello World

fn app(cx: &mut Context) -> NodeKey {
    Element::new()
        .align_items(AlignItems::Center)
        .justify_content(JustifyContent::Center)
        .child(cx.insert("Hello World!"))
        .build(cx)
}

fn main() {
    viewbuilder::run(app)
}

Scroll

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)
}

Button Component

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)
}