Skip to content

Menu presets and options ​

Publish the config:

bash
php artisan vendor:publish --tag=filament-relation-navigator-config
php
'menu' => [
    'preset' => 'github',   // 'simple', a preset of yours, or a view name
    'presets' => [
        'simple' => 'filament-relation-navigator::menu.simple',
        'github' => 'filament-relation-navigator::menu.github',
    ],
    'searchable' => true,   // a search field on top of the list, whatever the preset
    'search_from' => 0,     // ...from this many items
    'badges' => true,       // the relation managers' badges; 'lazy' loads them when the menu opens
    'max_height' => '24rem',
    'separator' => true,    // record pages and relation pages in two blocks
    'mobile' => true,       // the menu above the heading on small screens
    'shortcut' => 'alt+shift+r', // opens the menu; null turns it off
],

github (the default): the last breadcrumb stays text and a caret next to it opens a panel with a heading, a search field and a check on the current page, like GitHub's repository switcher. The field gets the focus when the menu opens and Enter opens the first match.

simple: the last breadcrumb itself opens the list. For the menu of 1.2 and earlier, set 'preset' => 'simple' and 'searchable' => false.

The simple preset on the view page

Deferred badges ​

Badges run the same queries as the tab badges. With 'badges' => 'lazy' the page renders without them, and the menu loads them in one request when it opens.

A relation manager whose tab badge is lazy in Filament (protected static ?bool $isBadgeLazyLoaded = true;, or $isBadgeDeferred on Filament 4.13) gets the same treatment in the menu, whatever the config: its badge is loaded when the menu opens, the others with the page.

If you published the package views, update menu/partials/list.blade.php before relying on either.

Keyboard: from the search field, Down moves into the list; Up and Down move between the pages, Enter opens one, Escape closes the menu.

Shortcut and tooltip ​

The tooltip of the menu button with its shortcut

The button that opens the menu has a tooltip with the shortcut, shown with Mac or Windows/Linux keys. The shortcut opens the menu from anywhere on the page, with the search field ready, like GitHub's repository switcher: ⌥ ⇧ R on a Mac, Alt Shift R elsewhere. Change it in the config or per page:

php
'shortcut' => 'mod+shift+p', // mod is ⌘ on a Mac and Ctrl elsewhere
php
public function getRelationNavigatorShortcut(): ?string
{
    return null; // no shortcut on this page
}

It is built not to get in the way:

  • it matches the physical key, so it works with any keyboard layout and with Option on a Mac (where ⌥⇧R types ‰);
  • it does nothing while you type in a field;
  • a shortcut of the panel's global search (globalSearchKeyBindings()) is never taken: the menu then has no shortcut;
  • only the visible menu opens (breadcrumbs or small screens).

Supported keys: alt, shift, ctrl, meta, mod plus a letter, a digit or / . , ;.

The github preset with the search field

Page, resource or config ​

Every option has three levels. The page wins, then the resource, then the config:

Page method (static on the resource)Config key
getRelationNavigatorPreset(): stringmenu.preset
isRelationNavigatorSearchable(): boolmenu.searchable
hasRelationNavigatorBadges(): boolmenu.badges
hasDeferredRelationNavigatorBadges(): boolmenu.badges = 'lazy'
getRelationNavigatorShortcut(): ?stringmenu.shortcut
hasRelationNavigatorMobileMenu(): boolmenu.mobile
hasRelationNavigatorRecordNavigation(): boolrecord_navigation
shouldRelationNavigatorRecordNavigationFollowList(): boolrecord_navigation_follows_list
shouldRedirectRelationNavigatorTabs(): boolredirect_relation_tabs
php
// On one page
public function isRelationNavigatorSearchable(): bool
{
    return false;
}
php
// On a resource: the same method, static, for all its pages
public static function hasRelationNavigatorRecordNavigation(): bool
{
    return true;
}

Small screens ​

Filament hides the breadcrumbs below 40rem. There the menu shows above the page heading instead, on every page that uses HasRelationNavigator, with the same preset options. Turn it off with 'mobile' => false, or per page:

php
public function hasRelationNavigatorMobileMenu(): bool
{
    return false;
}
The menu on a phone, above the page heading

Translations ​

English, Italian, Spanish, German, French, Brazilian Portuguese and Dutch. Publish the translations to change them or add a language:

bash
php artisan vendor:publish --tag=filament-relation-navigator-translations

A preset of your own ​

Start from one of the package presets:

bash
php artisan make:filament-relation-navigator-preset compact --from=github

It copies the preset to resources/views/filament/relation-navigator/compact.blade.php. Register it and change it as you like:

php
'preset' => 'compact',
'presets' => [
    // ...
    'compact' => 'filament.relation-navigator.compact',
],

Any view name works as preset too. To change the package presets themselves, publish their views:

bash
php artisan vendor:publish --tag=filament-relation-navigator-views

A preset view receives:

VariableContent
$labelThe last breadcrumb
$itemsThe menu items: key, label, url, icon, badge, badgeColor, isActive
$heading"Switch page", translated
$isSearchableWhether to show the search field
$hasSeparatorWhether to split record pages and relation pages in two blocks
$shortcutThe shortcut, or null
$shortcutKeysThe shortcut keys to show: ['mac' => [...], 'other' => [...]]
$searchPlaceholder"Find a page…", translated
$emptyLabel"No pages found.", translated
$maxHeightmenu.max_height

To give your button the tooltip and the shortcut, include filament-relation-navigator::menu.partials.trigger-attributes inside its tag. Each item also has isRelationPage(). To reuse the search field, the list (with the separator and the keyboard navigation) and the "no results" line, include filament-relation-navigator::menu.partials.list with showCheck.

Released under the MIT License.