readme.rs 472 B

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