Skip to content
Discussion options

You must be logged in to vote

Sure, you can implement a function like this -- it's mostly just that some of the builder patterns have changed to accommodate the type system, so the changes here have been relatively bigger than in typical code. But here's a version of the function above that compiles

fn el_with_attributes(
    e: HtmlElement,
    inside: AnyView,
    attributes: ElementAttributes<Callback<MouseEvent>>,
) -> AnyView {
    use leptos::ev::{click, on};
    use leptos::tachys::html::class::class;
    use leptos::tachys::html::style::style;

    let r: AnyView = match e {
        HtmlElement::Div => html::div().child(inside).into_any(),
        HtmlElement::Span => html::span().child(inside).into_any(),

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@povilasb
Comment options

@gbj
Comment options

gbj Jun 17, 2025
Maintainer

Answer selected by povilasb
@povilasb
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants