search Esc

Sidebar

Config-driven layout chrome: pin/unpin on desktop, slide-in drawer on mobile, nested submenus, a choice of top- or bottom-positioned mobile navbar, and a full custom-event surface. Everything below is driven by a single PHP $sidebar array.

Config shape

The sidebar partial expects one scoped $sidebar array. Every consumer-level option — nav structure, brand, footer actions, current page, mobile toggle position — lives here.

Navigation items

Each navigation section has a title and an items array. An item is either a leaf (has url) or a parent (has children). Parents nest to any depth and render recursively.

Mobile navbar position

Resize the browser below 992px to see the current variant in action. This page is configured with mobileToggle: 'bottom', so the entire navbar — including the hamburger — moves to the bottom edge of the viewport. Dropdowns inside the navbar flip upward.

menu Navbar
top (default) — navbar at the top of the viewport.
menu Navbar
bottom — whole navbar pinned to the bottom, thumb-friendly on phones.
Event surface

Every sidebar interaction bubbles a CustomEvent up to document. The table below lists each event and its detail payload.

Event When Detail
lp:sidebar:initAfter constructor (base Component)
lp:sidebar:readyAfter active path expanded & scrolled into view
lp:sidebar:toggleBefore open/close branch (mobile only){ willOpen: bool }
lp:sidebar:openStart of mobile drawer open
lp:sidebar:openedEnd of open transition
lp:sidebar:closeStart of mobile drawer close
lp:sidebar:closedEnd of close transition
lp:sidebar:pinPin state toggled (desktop, Ctrl+B){ pinned: bool }
lp:sidebar:item:expandSubmenu opened{ element, key, depth }
lp:sidebar:item:collapseSubmenu closed{ element, key, depth }
lp:sidebar:item:clickLeaf link clicked (observability only){ element, key, url }

Programmatic toggle: dispatch lp:sidebar:toggle-request on document. The same event is fired by the bottom hamburger button and the legacy lp:navbar:toggle-sidebar event is still honoured for back-compat.

Live event log

Interact with the real sidebar on the left — click any item, open/close a submenu, press Ctrl+B to toggle pin, or tap the bottom hamburger on a narrow viewport. Every event appears here in real time.