update the dioxus cratesio readme, add many more examples (#5501)

* update the dioxus cratesio readme

* fix example

* fix header

* add a bunch more examples
This commit is contained in:
Jonathan Kelley authored and GitHub committed 2026-04-21 17:07:48 -07:00
1 parent 74e7d20f80
commit cd54f5953b
30 files changed
+1403 -235

No files matched your search

+43
View File
@@ -0,0 +1,43 @@
//! Controlled text inputs.
//!
//! To read text from an input, attach an `oninput` handler and call `evt.value()` to get the
//! current value as a `String`. Binding the `value:` attribute to a signal makes the input
//! "controlled" — the signal is the single source of truth, so clearing it clears the input.
use dioxus::prelude::*;
fn main() {
dioxus::launch(app);
}
fn app() -> Element {
let mut name = use_signal(String::new);
let mut message = use_signal(|| "Type something below.".to_string());
rsx! {
h1 { "Hello, {name}!" }
input {
r#type: "text",
placeholder: "Your name",
// Binding `value` to a signal makes this a controlled input
value: "{name}",
oninput: move |evt| name.set(evt.value()),
}
button {
onclick: move |_| name.set(String::new()),
"Clear"
}
hr {}
p { "{message}" }
textarea {
rows: 3,
cols: 40,
value: "{message}",
oninput: move |evt| message.set(evt.value()),
}
}
}