saadeghi / daisyui

๐ŸŒผ ๐ŸŒผ ๐ŸŒผ ๐ŸŒผ ๐ŸŒผ โ€ƒThe most popular, free and open-source Tailwind CSS component library
https://daisyui.com
MIT License
34.13k stars 1.3k forks source link

docs: How to maintain state of collapse and expand submenu? #3264

Closed vishal-ainow closed 2 weeks ago

vishal-ainow commented 2 weeks ago

On which page do you see this issue?

https://daisyui.com/components/menu/

Describe the issue

How to maintain state of collapse and expand submenu? in documentation its only <details open> tag. I'm using astro + svelte.

Screenshot 2024-11-07 at 2 50 33โ€ฏAM

What browsers are you seeing the problem on?

All browsers

github-actions[bot] commented 2 weeks ago

Thank you @vishal-ainow for reporting issues. It helps daisyUI a lot ๐Ÿ’š
I'll be working on issues one by one. I will help with this one as soon as a I find a solution.
In the meantime providing more details and reproduction links would be helpful.

saadeghi commented 2 weeks ago

Here's docs for HTML <details> tag:
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/details

Adding or removing open attribute opens or closes the menu. This happens automatically with click (no JS needed) But you can add/remove the open attribute using JS if you want to.

Also if you don't want to use <details> tag you can use spans and class names to get the same UI: https://daisyui.com/components/menu/#collapsible-submenu-that-works-with-class-names

Let me know if you have a question.

vishal-ainow commented 1 week ago

@saadeghi Is it possible to get click event of <details> tag?