18 releases (6 breaking)

0.7.0 Sep 18, 2023
0.6.8 Sep 16, 2023
0.6.3 Aug 29, 2023
0.5.0 Aug 26, 2023
0.1.0 Jan 23, 2023

#101 in GUI

Download history 1/week @ 2023-06-03 1/week @ 2023-06-10 3/week @ 2023-06-17 1/week @ 2023-06-24 56/week @ 2023-07-01 11/week @ 2023-07-08 6/week @ 2023-07-15 26/week @ 2023-07-22 4/week @ 2023-07-29 38/week @ 2023-08-05 23/week @ 2023-08-12 5/week @ 2023-08-19 108/week @ 2023-08-26 6/week @ 2023-09-02 3/week @ 2023-09-09 205/week @ 2023-09-16

322 downloads per month
Used in staff

MIT/Apache

62KB
896 lines

logo

Rust cross-platform reactive UI framework.

enum Event {
    Increment,
    Decrement,
}

fn counter(count: &i32) -> impl View<Web<Event>> {
    (
        Html::h1().view(count.to_string()),
        view::once(
            Html::button()
                .on("click", |_| Event::Increment)
                .view("More"),
        ),
        view::once(
            Html::button()
                .on("click", |_| Event::Decrement)
                .view("Less"),
        ),
    )
}

fn main() {
    concoct::web::run(
        0,
        |count, event| match event {
            Event::Increment => *count += 1,
            Event::Decrement => *count -= 1,
        },
        counter,
    );
}

Features

  • Cross-platform components
  • Compile-time UI tree
  • Efficient view updates
  • Inspired by the elm and xilem architectures

Getting started

Web

Install trunk or wasm-pack (this tutorial will show serving with trunk).

cargo add concoct --features web

Create an index.html file in the crate root

<html>
    <body></body>
</html>

Create a main view and run it with Concoct

fn app(_state: &()) -> impl View<Web<()>> {
    Html::h1((), "Hello World!"),
}

fn main() {
    concoct::web::run(
        0,
        |_state, _event| {},
        app,
    );
}
trunk serve

All done! Check it out at http://localhost:8080

Dependencies

~1–18MB
~220K SLoC