-
Notifications
You must be signed in to change notification settings - Fork 151
Expand file tree
/
Copy pathform.rs
More file actions
135 lines (122 loc) · 3.74 KB
/
form.rs
File metadata and controls
135 lines (122 loc) · 3.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
//! Drive the renderer from Dioxus
use dioxus::prelude::*;
fn main() {
dioxus_native::launch(app);
}
fn app() -> Element {
let mut checkbox_checked = use_signal(|| false);
rsx! {
div { class: "container",
style { {CSS} }
form {
div {
input {
r#type: "checkbox",
id: "check1",
name: "check1",
value: "check1",
checked: checkbox_checked(),
// This works too
// checked: "{checkbox_checked}",
oninput: move |ev| checkbox_checked.set(ev.checked()),
}
label { r#for: "check1", "Checkbox 1 (controlled)" }
}
div {
input {
r#type: "checkbox",
id: "check3",
name: "check3",
value: "check3",
}
label { r#for: "check3", "Checkbox 1 (uncontrolled with for)" }
}
div {
label {
input {
r#type: "checkbox",
name: "check2",
value: "check2",
}
"Checkbox 2 (uncontrolled nested)"
}
}
div {
label { r#for: "radio1", id: "radio1label",
input {
r#type: "radio",
name: "radiobuttons",
id: "radio1",
value: "radiovalue1",
checked: true,
}
"Radio Button 1"
}
}
div {
label { r#for: "radio2", id: "radio2label",
input {
r#type: "radio",
name: "radiobuttons",
id: "radio2",
value: "radiovalue2",
}
"Radio Button 2"
}
}
div {
label { r#for: "radio3", id: "radio3label",
input {
r#type: "radio",
name: "radiobuttons",
id: "radio3",
value: "radiovalue3",
}
"Radio Button 3"
}
}
div {
input { r#type: "file", name: "single_file", id: "file1" }
label { r#for: "file1", "File Select Single" }
}
div {
input {
r#type: "file",
name: "multiple_files",
id: "file2",
multiple: true,
}
label { r#for: "file2", "File Select Multiple" }
}
}
div { "Checkbox 1 checked: {checkbox_checked}" }
}
}
}
const CSS: &str = r#"
.container {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 100vh;
width: 100vw;
}
form {
margin: 12px 0;
display: block;
}
form > div {
margin: 8px 0;
}
label {
display: inline-block;
}
input {
/* Should be accent-color */
color: #0000cc;
}
input[type=radio]:checked {
border-color: #0000cc;
}
"#;