readme.rs 441 B

1234567891011121314151617181920
  1. //! Example: README.md showcase
  2. //!
  3. //! The example from the README.md.
  4. use dioxus::prelude::*;
  5. #[tokio::main]
  6. async fn main() {
  7. dioxus_desktop::launch(app).await;
  8. }
  9. fn app(cx: Scope) -> Element {
  10. let mut count = use_state(cx, || 0);
  11. cx.render(rsx! {
  12. h1 { "High-Five counter: {count}" }
  13. button { onclick: move |_| count += 1, "Up high!" }
  14. button { onclick: move |_| count -= 1, "Down low!" }
  15. })
  16. }