Skip to content

Groups

Entries with the same navigationGroup() are shown together under a heading. Panel::navigationGroups() sets the order of the groups and their options; it takes labels or NavigationGroup objects:

use Anvil\Panel\Navigation\NavigationGroup;
public function navigationGroups(): array
{
return [
'Sales',
NavigationGroup::make('Reports')->icon('bar-chart')->collapsible(),
NavigationGroup::make('Settings')->icon('gear')->collapsed(),
];
}
Option Effect
NavigationGroup::make('Label') the group; the label must match navigationGroup() of the entries exactly
icon('gear') icon before the group label
collapsible() the user can collapse the group; it starts open
collapsed() collapsible and starts collapsed
  • Entries without a group come first.
  • Then the groups in the order of navigationGroups().
  • Groups that are not listed follow alphabetically, without icon and not collapsible.
  • A group without an entry the user may open is not shown at all.
  • The browser remembers per panel and group whether the user opened or closed it; collapsed() is only the start state.
  • A group with the active entry always starts open, so the user sees where they are.
  • With the sidebar reduced to icons, the groups are ignored and all entries are shown.

Collapse groups that are used rarely (settings, administration) and keep the daily work open.

Anvil’s pages for users, roles, API clients and workflow settings are in the group “Access” (language key Anvil.access.group, “Zugriff” in German). List it in navigationGroups() to place or collapse it:

public function navigationGroups(): array
{
return [
'Sales',
NavigationGroup::make(lang('Anvil.access.group'))->icon('shield-lock')->collapsed(),
];
}

The profile is only in the user menu; the inbox has no group.

The label is the key of the group. If entries return lang('App.nav.sales'), use the same call in navigationGroups(), so both are translated the same way.