material_dioxus/
form_field.rs1use dioxus::prelude::*;
2use wasm_bindgen::prelude::*;
3
4#[wasm_bindgen(module = "/build/mwc-formfield.js")]
5extern "C" {
6 #[derive(Debug)]
7 type Formfield;
8
9 #[wasm_bindgen(getter, static_method_of = Formfield)]
10 fn _dummy_loader() -> JsValue;
11}
12
13loader_hack!(Formfield);
14
15#[derive(Props)]
19pub struct FormfieldProps<'a> {
20 pub children: Element<'a>,
21 #[props(into)]
22 pub label: Option<String>,
23 #[props(default)]
24 pub align_end: bool,
25 #[props(default)]
26 pub space_between: bool,
27 #[props(default)]
28 pub nowrap: bool,
29
30 #[props(into, default)]
31 pub style: String,
32 #[props(into, default)]
33 pub class: String,
34 #[props(into)]
35 pub slot: Option<String>,
36 #[props(default)]
37 pub dialog_initial_focus: bool,
38}
39
40fn render<'a>(cx: Scope<'a, FormfieldProps<'a>>) -> Element<'a> {
41 render! {
42 mwc-formfield {
43 label: optional_string_attr!(cx.props.label),
44 alignEnd: bool_attr!(cx.props.align_end),
45 spaceBetween: bool_attr!(cx.props.space_between),
46 nowrap: bool_attr!(cx.props.nowrap),
47
48 style: string_attr!(cx.props.style),
49 class: string_attr!(cx.props.class),
50 slot: optional_string_attr!(cx.props.slot),
51 dialogInitialFocus: bool_attr!(cx.props.dialog_initial_focus),
52
53 &cx.props.children
54 }
55 }
56}
57
58component!('a, MatFormfield, FormfieldProps, render, Formfield, "formfield");