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
322 downloads per month
Used in staff
62KB
896 lines
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