Skip to content

How to close Tailwind DaisyUI dropdown? #1536

Answered by gbj
gitmalong asked this question in Q&A
Discussion options

You must be logged in to vote

Using their "Method 1: Details and summary" and the open property on <details>:

#[component]
pub fn App(cx: Scope) -> impl IntoView {
    let (open, set_open) = create_signal(cx, false);

    view! { cx,
        <details class="dropdown mb-32" prop:open=open>
            <summary class="m-1 btn">"open or close"</summary>
            <ul class="p-2 shadow menu dropdown-content z-[1] bg-base-100 rounded-box w-52">
                <li><a on:click=move |_| set_open(false)>"Item 1"</a></li>
                <li><a on:click=move |_| set_open(false)>"Item 2"</a></li>
            </ul>
        </details>
    }
}

That's what I'd do, personally.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by gitmalong
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