disabled.rs 731 B

123456789101112131415161718192021222324
  1. //! A simple demonstration of how to set attributes on buttons to disable them.
  2. //!
  3. //! This example also showcases the shorthand syntax for attributes, and how signals themselves implement IntoAttribute
  4. use dioxus::prelude::*;
  5. fn main() {
  6. dioxus::launch(app);
  7. }
  8. fn app() -> Element {
  9. let mut disabled = use_signal(|| false);
  10. rsx! {
  11. div { style: "text-align: center; margin: 20px; display: flex; flex-direction: column; align-items: center;",
  12. button { onclick: move |_| disabled.toggle(),
  13. "click to "
  14. if disabled() { "enable" } else { "disable" }
  15. " the lower button"
  16. }
  17. button { disabled, "lower button" }
  18. }
  19. }
  20. }