Skip to content

crate

weft

Weft

A reactive, component-based Rust/WebAssembly UI framework with 2D and 3D graphics and a built-in accessibility (semantic) layer.

use weft::prelude::*;

fn counter() -> Component {
    Component::new("Counter", template! {
        column(gap: 8) {
            heading(level: 1) "Count: {count}"
            button(@click: inc, label: "Increment") "+"
        }
    }, |_props| {
        let count = Signal::new(0);
        let c = count.clone();
        Scope::new().signal("count", &count).handler("inc", move |_| c.update(|n| *n += 1))
    })
}

// In the browser:
weft::web::start("#app", counter(), Registry::new()).unwrap();

Modules

  • prelude

    Everything needed to write components.

  • site

    Prerendering pages to static HTML.

Macros

app

macro_rules! app {
    () => { ... };
}

The pages, layouts and components in app/ and components/, as the module weft_app: weft_app::ROUTES, weft_app::registry(base), weft_app::root(path). The project's build.rs generates them with weft_build::run().

Re-exports

  • *
  • web
  • ui
  • motion
  • pub use weft_macros::template;
  • pub use weft_macros::include_template;
  • data