-
Hi! I am very new to Leptos and I am wondering how I could properly close a Dropdown after an entry was selected/clicked Given the following: https://daisyui.com/components/dropdown/
<div class="dropdown">
<label tabindex="0" class="btn m-1">Entries { move || entry().to_string() }</label>
<ul tabindex="0" class="dropdown-content z-[1] menu p-2 shadow bg-base-100 rounded-box w-52">
<li><a on:click=move |_| set_entry.update(|entry| *entry = "1")>1</a></li>
<li><a on:click=move |_| set_entry.update(|entry| *entry = "2")>2</a></li>
</ul>
</div> Thanks! |
Beta Was this translation helpful? Give feedback.
Answered by
gbj
Aug 13, 2023
Replies: 1 comment
-
Using their "Method 1: Details and summary" and the #[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. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
gitmalong
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Using their "Method 1: Details and summary" and the
open
property on<details>
:That's what I'd do, personally.