skip to Main Content

I used mary-ui with livewire-volt in laravel 10 project,but I dion’t know how to set expand to open by default.

            <x-menu-item title="xxxx" icon="o-building-storefront" link="/" />
            <x-menu-item title="xxxxx" icon="o-shopping-cart" link="/" />
            <x-menu-sub title="xxxxx" icon="o-cog-6-tooth"> // want to expand this without active.
                <x-menu-item title="xxxx" icon="o-wifi" link="####"  />
                <x-menu-item title="xxxxx" icon="o-archive-box" link="####" />
            </x-menu-sub>

set expand by default without active in livewire-volt syntax.

2

Answers


  1. Chosen as BEST ANSWER

    i found solution but not beatiful. can do any else?

    <script>
        let submenu = document.querySelector("summary")
        console.log(submenu);
         setTimeout(() => {
            submenu.click()
         }, 500);
    </script>
    

  2. You can force it open with this special class placed on any children menu.

    class="mary-active-menu" 
    
    <x-menu-sub title="Settings" icon="o-cog-6-tooth">
          <x-menu-item title="Wifi" icon="o-wifi" class="mary-active-menu" />
          <x-menu-item title="Archives" icon="o-archive-box" />
    </x-menu-sub>
    

    This is not documented because it is not a recommend approach. It really depends what design you intend with this.

    Tip: Open a GitHub "question" issue, so more people can help you.
    https://github.com/robsontenorio/mary

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search