Explorar o código

feat: add disabled example

Jonathan Kelley %!s(int64=3) %!d(string=hai) anos
pai
achega
3d90a2616d
Modificáronse 1 ficheiros con 23 adicións e 0 borrados
  1. 23 0
      examples/disabled.rs

+ 23 - 0
examples/disabled.rs

@@ -0,0 +1,23 @@
+use dioxus::prelude::*;
+
+fn main() {
+    dioxus::desktop::launch(app);
+}
+
+fn app(cx: Scope) -> Element {
+    let disabled = use_state(&cx, || false);
+
+    cx.render(rsx! {
+        div {
+            button {
+                onclick: move |_| disabled.set(!disabled.get()),
+                "click to " [if *disabled {"enable"} else {"disable"} ] " the lower button"
+            }
+
+            button {
+                disabled: "{disabled}",
+                "lower button"
+            }
+        }
+    })
+}