Skip to content
Viames Marino edited this page Oct 19, 2026 · 3 revisions

Pair framework: Menu

Pair\Html\Menu builds navigation menus with active item detection, dropdown groups, and Font Awesome integration.

Main methods

  • item(string $url, string $title, ?string $icon = null, ?string $badge = null, ?string $badgeType = null, ?string $target = null): void
  • group(string $title, array $items, ?string $icon = null): void
  • fontAwesomeStyle(string $style): void
  • fontAwesomeSize(string $size): void
  • render(): string
  • title(string $title): void
  • separator(?string $title = null): void

Implementation example

$menu = new \Pair\Html\Menu();
$menu->fontAwesomeStyle('fa-solid');
$menu->fontAwesomeSize('fa-sm');

$menu->item('dashboard', 'Dashboard', 'fa-house');
$menu->group('Settings', [
    ['users', 'Users', 'fa-user'],
    ['roles', 'Roles', 'fa-shield'],
]);

echo $menu->render();

Notes

  • Active menu item is resolved from Application::menuUrl or current router module/action.
  • Group items support both tuple and associative array item definitions.
  • Builders return void; call item() and group() separately instead of chaining them.
  • Active detection uses an exact string match. Match the application's menuUrl or router module/action format when choosing item URLs.
  • render() returns entries, not an enclosing <ul>. The layout owns the list wrapper and the matching CSS/JavaScript.
  • Rendering consults the current user's ACL. A group with no permitted children produces no dropdown; keep permission checks in the controller as well.

See also: BootstrapMenu, Breadcrumb, Application.

Clone this wiki locally