dioxus/examples/readme.rs

20 lines
375 B
Rust
Raw Normal View History

2021-07-06 12:13:00 -04:00
//! Example: README.md showcase
//!
2021-07-11 19:31:07 -04:00
//! The example from the README.md.
2021-07-06 12:13:00 -04:00
use dioxus::prelude::*;
2021-12-29 21:28:28 -05:00
2021-07-06 12:13:00 -04:00
fn main() {
launch(app);
2021-07-06 12:13:00 -04:00
}
fn app() -> Element {
2024-01-13 21:12:21 -08:00
let mut count = use_signal(|| 0);
2021-07-06 12:13:00 -04:00
2024-01-13 21:12:21 -08:00
rsx! {
2022-03-05 16:57:09 -05:00
h1 { "High-Five counter: {count}" }
2022-03-05 17:07:34 -05:00
button { onclick: move |_| count += 1, "Up high!" }
button { onclick: move |_| count -= 1, "Down low!" }
2024-01-13 21:12:21 -08:00
}
}