-
I have an external library which exports Custom Elements, I'm trying to wrap these in Leptos elements like so: #[component]
fn MdTextField(cx: Scope, #[prop(optional, into)] label: Option<String>) -> impl IntoView {
custom(cx, Custom::new("md-outlined-text-field")).prop("label", label)
} This works fine. But what I can't figure out is to do the same thing while also adding children: #[component]
fn MdDialog(cx: Scope, children: Children) -> impl IntoView {
custom(cx, Custom::new("md-dialog"))
// This method doesn't exist
.children(children)
} I've scanned through the source code and documentation, but I couldn't find the proper way to pass the children. Is this even currently possible with Custom Elements? I'm willing to create a PR for it if pointed in the right direction to start. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Oh yeah totally possible. The syntax in the builder to add a child or children to any element is #[component]
fn MdDialog(cx: Scope, children: Children) -> impl IntoView {
custom(cx, Custom::new("md-outlined-text-field"))
.child(children(cx))
} or, if you want to add each child separately without the fragment, something like #[component]
fn MdDialog(cx: Scope, children: Children) -> impl IntoView {
let children = children(cx);
let el = custom(cx, Custom::new("md-outlined-text-field"));
children
.nodes
.into_iter()
.fold(el, |el, child| el.child(child))
} BTW Are you working on a Material Design wrapper library for Leptos? I'd love to share it with the community when it's ready! |
Beta Was this translation helpful? Give feedback.
Oh yeah totally possible. The syntax in the builder to add a child or children to any element is
.child()
. So for example you could door, if you want to add each child separately without the fragment, something like
BTW Are you working on a Material Design wrapper l…