For the complete documentation index, see llms.txt. This page is also available as Markdown.

x-header-dropdown (Analog)

The header's dropdown menu: a small panel of links that floats under a top-level nav item.

The header's dropdown menu: a small panel of links that floats under a top-level nav item.

Directive / magic
What it does

x-header-dropdown="menuId"

The root. Registers the element as the dropdown popup for that menu id (required)

x-header-dropdown:panel

Shows the inner panel while this dropdown is the active popup

$headerMenuPopup

The popup state from header-menu: isVisible, close(), and more

The root registers with the headerMenu store as a dropdown popup and floats under the active nav item: bottom-start, matching the item's width, flipping and shifting when out of room. Position updates only run while the dropdown is visible, because the reference element changes with the active nav item. Opening and closing, hover delays, and keyboard handling come from header-menu. This plugin only positions and shows the panel. The directive throws when the menu id is missing.

Examples

A dropdown panel

Use x-header-dropdown with the link's menu id, and x-header-dropdown:panel on the content:

<div x-header-dropdown="{{ menu_id }}" class="absolute z-50" x-cloak>
  <div x-header-dropdown:panel x-transition:enter="…" x-transition:leave="…">
    <ul>
      <li><a href="…">Shirts</a></li>
      <li><a href="…">Trousers</a></li>
    </ul>
  </div>
</div>

x-header-dropdown:panel is an x-show on $headerMenuPopup.isVisible, so x-transition on the same element animates the open and close.

Use $headerMenuPopup.isVisible directly to run a second animation inside the panel:

The theme's dropdown fades its link list in after the panel clip animation. The --header-menu-dropdown-enter-duration variable sets the delay.

Customizing

Analog renders one dropdown per top-level link whose sub-links go one level deep, through the header-dropdown snippet; links with deeper trees get a megamenu instead (see x-megamenu). Dropdowns only open from the desktop nav, so the snippet defers Alpine on phones with data-lazy-alpine="desktop". For how header menus behave in the theme editor, see Header.

Last updated

Was this helpful?