PetalComponents.NavigationMenu (petal_components v4.1.2)

Copy Markdown View Source

A horizontal navigation menu with flyout panels — the pattern marketing sites use for "Products / Solutions / Resources" menus that hold more than a simple dropdown can.

Follows the W3C disclosure navigation pattern (recommended for site navigation over ARIA menu roles): each trigger is a button with aria-expanded/aria-controls, panels contain plain links, Escape and clicking away close any open panel. Interaction is click-to-toggle (touch friendly) and 100% LiveView.JS — no Alpine, no hooks.

Panels are free-form: compose them from navigation_menu_link/1 rows (icon + title + description), an optional navigation_menu_footer/1 CTA strip, or any markup you like.

Staying on screen

Flyout panels anchor to their trigger's start edge and open rightward into the page (so a left-most trigger never opens back under a sidebar). For a trigger near the right edge, set align="end" on the item so its panel opens leftward instead and stays on screen. Panel widths are clamped to the viewport so a wide panel shrinks to fit instead of overflowing on a phone, and a panel taller than the screen scrolls rather than being cut off at the bottom.

Full-width (mega menu) panels

Set full_width on an item and the panel spans the nearest positioned ancestor — give your site header class="relative" and the panel becomes a full-width mega menu below it.

Summary

Functions

Renders the navigation menu.

A full-bleed strip at the bottom of a flyout panel, usually holding one to three navigation_menu_footer_link/1 CTAs.

A flyout panel row: icon in a tinted square, bold title, muted one-line description.

Functions